dqve65954 2010-08-16 12:57
浏览 102
已采纳

PHP错误:“mysqli_num_rows()期望参数1为mysqli_result,null为”

There isnt an actual error, but it's still displaying an error message when a user who is not the buyer or seller goes to the page. Is it possible to suppress the error message?

Direct link to images

alt text

alt text

  //transaction id
$transactionid = $_GET['id'];

//Retrieve info about transaction
$query = "SELECT ads.*, feedback.*, transactions.* FROM (ads INNER JOIN transactions ON ads.id=transactions.ad_id) INNER JOIN feedback ON transactions.id=feedback.transaction_id WHERE transaction_id = '$transactionid'";
$data = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($data);
$seller = $row['seller'];
$buyer = $row['buyer'];

//check if user is buyer or seller
if ($_SESSION['user_id'] == $seller) {
    $query = "SELECT * FROM feedback WHERE transaction_id = '$transactionid' AND seller_comment IS NULL";
    $data1 = mysqli_query($dbc, $query);
} else if ($_SESSION['user_id'] == $buyer) {
    $query = "SELECT * FROM feedback WHERE transaction_id = '$transactionid' AND buyer_comment IS NULL";
    $data1 = mysqli_query($dbc, $query);
}

//if user is buyer/seller echo form to them to submit feedback
if (mysqli_num_rows($data1) == 1) {
    echo '<p><form method="post" action="feedback.php?id=' . $transactionid . '&action=submitfeedback">
    <textarea id="feedback" name="feedback" rows="10" cols="30"></textarea><br/>
<input type="submit" value="Submit" name="submit" /></form></p>';
} else {
    echo '<p>feedback already given</p>';
}
  • 写回答

4条回答 默认 最新

  • donglie7268 2010-08-16 13:00
    关注

    You may want to resolve the warning, not just cover it up. You should be able to resolve this by changing the if statement to:

    if(!empty($data1) && mysql_num_rows($data1) == 1) {
    

    The problem is trying to pass NULL to the mysql function.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集