-3

i am trying to make web app for mobile repair management so far i have made it submit data to MySQL but whenever i try to retrieve data either displays blank page or it gives MySQL_num_rows() expects parameter 1 to be resource error

here is my code

<?php
   $connect = mysqli_connect('localhost','root','password','shopdata');
   if(mysqli_connect_errno($connect)){
echo 'FAILED';
 }
?>

<?php
  $result = mysqli_query($connect,"SELECT * FROM `jobsheets` ");
 ?>

<table width="1350" cellpadding=5 cellspacing=5 border=1>
<tr>
    <th>JOBSHEET NO.</th>
    <th>CUSTOMER NAME</th>
    <th>CUSTOMERS PH.</th>
    <th>MOBILE BRAND</th>
    <th>MODEL NAME</th>
    <th>IMEI NO.</th>
    <th>FAULT</th>
    <th>BATEERY</th>
    <th>BACKPANEL</th>
    <th>CONDITION</th
</tr>
<?php
If (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_array($result)) {
?>
    <tr>
        <td><?php echo $row['job_number']; ?></td>
        <td><?php echo $row['cust_name']; ?></td>
        <td><?php echo $row['cust_mob']; ?></td>
        <td><?php echo $row['mob_brand']; ?></td>
        <td><?php echo $row['mob_name']; ?></td>
        <td><?php echo $row['imei_number']; ?></td>
        <td><?php echo $row['fault_name']; ?></td>
        <td><?php echo $row['bat_status']; ?></td>
        <td><?php echo $row['panel_status']; ?></td>
        <td><?php echo $row['misc_note']; ?></td>
    </tr>

   </table>
   <?php
     }
   }
   ?>**strong text**
  • Use `mysqli_num_rows($result);` instead of `mysql_num_rows($result);` – Ani Menon Apr 21 '16 at 09:32
  • update your "If (mysql_num_rows($result) > 0) {" to "If (mysqli_num_rows($result) > 0) {" and " while ($row = mysql_fetch_array($result)) { " to " while ($row = mysqli_fetch_array($result)) { " – Dipanwita Kundu Apr 21 '16 at 09:40

1 Answers1

-1

You can't combine the mysql_ and mysqli_ functions. Anything that starts with mysql_ is now officially deprecated, so you should move to using mysqli_ or ideally PDO.

http://php.net/manual/en/book.mysqli.php

http://php.net/manual/en/book.pdo.php

iainn
  • 16,826
  • 9
  • 33
  • 40