douju2599 2014-01-14 20:23
浏览 100
已采纳

警告:mysql_num_rows()期望参数1是资源,我的php文件中给出了boolean [duplicate]

I have an error which was coming from this code the errors is

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/quick/public_html/tvhd.in/xamii/Channel-Detail.php on line 62


Warning: Cannot modify header information - headers already sent by (output started at /home/quick/public_html/tvhd.in/xamii/Channel-Detail.php:62) in /home/quick/public_html/tvhd.in/xamii/Channel-Detail.php on line 64

an one could help thatwould be fine

</div>
  • 写回答

1条回答 默认 最新

  • dry18813 2014-01-14 20:28
    关注

    Error Checking. Error Checking. Error Checking!!!

    // $result will be boolean FALSE if there is a failure in the query
    // This is not the same as if there were 0 results
    $result = mysql_query('SELECT * FROM SOMETABLE');
    
    if (!$result) {
        // The query has an error, so you can't use mysql_num_rows
        die(mysql_error()); // <!-- This will tell you why. psuedo error checking!
    }
    
    // If we make it this far, its safe to use mysql_num_rows and $result
    $rows = mysql_num_rows($result);
    

    Now, stop using mysql_ functions! They are deprecated. A 5 second glance at the online documentation would have answered this question and told you not to use mysql_. See the big red box.

    http://us1.php.net/manual/en/function.mysql-query.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于logstash转发日志时发生的部分内容丢失问题
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?