doupian9798 2016-01-30 11:43 采纳率: 100%
浏览 227
已采纳

mysqli_num_rows()期望参数1为mysqli_result,[duplicate]

I have searched for the correct answer but none of it helped me with this error. I have a page called profile.php in which there are 3 different tabs with some informations generated from mysqli database. The problem is i have to show the orders in 3rd tab for which i have written some code. If no orders has been placed it should output "There are no orders placed till now!!". It shows the message but it also shows the warning.

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in D:\XAMPP\htdocs\WebProject\profile.php on line 211

Here is my code for third tab.

Code

<div id="menu3" class="tab-pane fade">
 <h3>My Orders</h3>
 <?php
 $q="select customers.*, orders.date,orders.status from orders inner join customers on orders.customerid=customers.serial_cust where customers.email='$email'" ;
 $result=mysqli_query($con,$q);
  if(mysqli_num_rows($result)>0){
  while($row=mysqli_fetch_array($result))
  {
   $custid=$row['serial_cust'];
    $ordersdate=$row['date'];
   echo "<tr>";
    echo "<h3>".$row['date']."</h3>";
    echo "<h3> Status: Dispatched -> </h3> <p>".$row['status']."</p>";
     echo"<table border='1'>";
     $query="select customers.*, order_detail.*,orders.date,orders.customerid,products.* from order_detail inner join orders on orders.serial=order_detail.orderid inner join products on products.productid=order_detail.productid  inner join customers on orders.customerid=customers.serial_cust where customers.serial_cust='$custid' and orders.date='$ordersdate' ";
     $sql=mysqli_query($con,$query);
     while($row=mysqli_fetch_array($sql))
     {
     ?>
     <tr>
     <td><image width="80px" height="90px" src="assets/<?php echo $row['product_image'] ?>"/></td>
     <td><?php echo $row['product_name']. " * ". $row['quantity']?></td>
      <td><?php echo $row['color'] ?></td>
       <td><?php echo $row['price'] ?></td>
        <td><?php echo $row['size'] ?></td>
        </tr>
    <?php
      }
      echo "</table>";
     }
     }
  else{
     echo "You have not place any orders yet!";
       }
       ?>
      </div>
</div>
  • 写回答

1条回答 默认 最新

  • doujilou3903 2016-01-30 12:06
    关注

    Propably you have error in your request. Use this code to debug it:

    $q="select customers.*, orders.date,orders.status from orders inner join customers on orders.customerid=customers.serial_cust where customers.email='$email'" ;
    $result=mysqli_query($con,$q);
    if (!$result)
        echo(mysqli_error($con));
    
    if(mysqli_num_rows($result)>0){
    ...
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入