اذهب إلى المحتوى
  • 0

مشكلة PHP في الكود query($sql_query); ?>

Saleh Kamal

السؤال

<!DOCTYPE html>
<html lang="ar">

<head>
    <link rel="icon"
        href="https://c0.klipartz.com/pngpicture/573/614/gratis-png-ng%C5%A9-hanh-s%C6%A1n-distrito-casa-apartamento-inmobiliaria-volta-redonda-venta-de-logotipos-de-bienes-raices.png" />
    <title>موقع تجريبي</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@300&display=swap" rel="stylesheet">
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" media="screen" href="home.css">
</head>

<body>
    <header>
        <div> <img src="a.png" alt="نظام تجريبي"> </div>
        <center>
            <div> <button>نقاط البيع</button> <button>أدارة المخزون</button> <button>33</button>
                <button>الشيكات</button> <button>الأستاذ العام</button> <button>إدارة النظام</button>
            </div>
        </center>
    </header>
    <?php $server = 'DESKTOP-PJDLJNR'; $database = 'Legacy'; $username = ''; $password = ''; $connection = new PDO("sqlsrv:Server=$server;Database=$database", $username, $password); if (!$connection) { die(print_r(sqlsrv_errors(), true)); } $sql_query = 'SELECT * FROM Problemss'; $result = $connection->query($sql_query); ?>
    <table border="1" width="100%">
        <tr>
            <th>11</th>
            <th>22</th>
            <th>33</th>
            <th>44</th>
            <th>55</th>
        </tr>
        <?php <?php while ($row = mysql_fetch_assoc($result)) { ?>
        <tr>
            <td>
                <?php echo $row['11']?>
            </td>
            <td>
                <?php echo $row['22']?>
            </td>
            <td>
                <?php echo $row['33']?>
            </td>
            <td>
                <?php echo $row['44']?>
            </td>
            <td>
                <?php echo $row['55']?>
            </td>
        </tr>
        <?php } $connection = null; // close the connection ?>
    </table>
</body>

</html>
رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 1

المشكلة غير واضحة تماما، ولكن يرجح أن هنالك خطأ في السياق سببه السطر التالي: 

<?php <?php while ($row = mysql_fetch_assoc($result)) { ?>

انتبه إلى أن <?php مكررة، 

احذفها في الموضع الأول أو الثاني، وأعد تشغيل الملف.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 1
بتاريخ 18 دقائق مضت قال كمال صالح محمد:

المشكلة استاذ عدنان  هي في الكود :$result = $connection->query($sql_query);

فماهو الحل من فضلك 

وهاذا توضيح الكود الكامل التالي :

<!DOCTYPE html>
<html lang="ar">
<head>
    <link rel="icon" href="https://c0.klipartz.com/pngpicture/573/614/gratis-png-ng%C5%A9-hanh-s%C6%A1n-distrito-casa-apartamento-inmobiliaria-volta-redonda-venta-de-logotipos-de-bienes-raices.png" />
    <title>موقع العقارات</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@300&display=swap" rel="stylesheet">
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" media="screen" href="home.css">
</head>
<body>
    <header>
        <div>
            <img src="a.png" alt="نظام العقارات من كمال تجريبي">
        </div>
        <center>
            <div>
                <button>نقاط البيع</button>
                <button>أدارة المخزون</button>
                <button>الإراضي</button>
                <button>الشيكات</button>
                <button>الأستاذ العام</button>
                <button>إدارة النظام</button>
            </div>
        </center>
    </header>

    <?php
    $server = 'DESKTOP-PJDLJNR';
    $database = 'Legacy';
    $username = '';
    $password = '';

    $connection = new PDO("sqlsrv:Server=$server;Database=$database", $username, $password);
    if (!$connection) {
    die(print_r(sqlsrv_errors(), true));
    }

    $sql_query = 'SELECT * FROM Problemss';
    $result = $connection->query($sql_query);
    ?>

    <table border="1" width="100%">
        <tr>
            <th>تم</th>
            <th>الحلول</th>
            <th>المشكلة</th>
            <th>م</th>
            <th>الرقم</th>
        </tr>


        <?php while ($row = mysql_fetch_assoc($result)) { ?>
        <tr>
            <td><?php echo $row['تم']?></td>
            <td><?php echo $row['الحلول']?></td>
            <td><?php echo $row['المشكلة']?></td>
            <td><?php echo $row['م']?></td>
            <td><?php echo $row['الرقم']?></td>
        </tr>
        <?php
        }
        $connection = null; // close the connection
        ?>
    </table>
</body>
</html>

 

ان كنت تستخدم MySQL فتأكد من تحديد ذلك في المعامل الأول لكائن PDO: 

new PDO("mysql:host=$server

عدا ذلك، لا يبدوا بالشيفرة أي مشكلة. 

ان كانت تظهر أي رسالة خطأ يرجى ارفاقها.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 11 دقائق مضت قال Adnane Kadri:

المشكلة غير واضحة تماما، ولكن يرجح أن هنالك خطأ في السياق سببه السطر التالي: 

<?php <?php while ($row = mysql_fetch_assoc($result)) { ?>

انتبه إلى أن <?php مكررة، 

احذفها في الموضع الأول أو الثاني، وأعد تشغيل الملف.

المشكلة استاذ عدنان  هي في الكود :$result = $connection->query($sql_query);

فماهو الحل من فضلك 

وهاذا توضيح الكود الكامل التالي :

<!DOCTYPE html>
<html lang="ar">
<head>
    <link rel="icon" href="https://c0.klipartz.com/pngpicture/573/614/gratis-png-ng%C5%A9-hanh-s%C6%A1n-distrito-casa-apartamento-inmobiliaria-volta-redonda-venta-de-logotipos-de-bienes-raices.png" />
    <title>موقع العقارات</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@300&display=swap" rel="stylesheet">
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" media="screen" href="home.css">
</head>
<body>
    <header>
        <div>
            <img src="a.png" alt="نظام العقارات من كمال تجريبي">
        </div>
        <center>
            <div>
                <button>نقاط البيع</button>
                <button>أدارة المخزون</button>
                <button>الإراضي</button>
                <button>الشيكات</button>
                <button>الأستاذ العام</button>
                <button>إدارة النظام</button>
            </div>
        </center>
    </header>

    <?php
    $server = 'DESKTOP-PJDLJNR';
    $database = 'Legacy';
    $username = '';
    $password = '';

    $connection = new PDO("sqlsrv:Server=$server;Database=$database", $username, $password);
    if (!$connection) {
    die(print_r(sqlsrv_errors(), true));
    }

    $sql_query = 'SELECT * FROM Problemss';
    $result = $connection->query($sql_query);
    ?>

    <table border="1" width="100%">
        <tr>
            <th>تم</th>
            <th>الحلول</th>
            <th>المشكلة</th>
            <th>م</th>
            <th>الرقم</th>
        </tr>


        <?php while ($row = mysql_fetch_assoc($result)) { ?>
        <tr>
            <td><?php echo $row['تم']?></td>
            <td><?php echo $row['الحلول']?></td>
            <td><?php echo $row['المشكلة']?></td>
            <td><?php echo $row['م']?></td>
            <td><?php echo $row['الرقم']?></td>
        </tr>
        <?php
        }
        $connection = null; // close the connection
        ?>
    </table>
</body>
</html>

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...