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){
    ...
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择