[英]mysql_num_rows(): supplied argument is not a valid MySQL result resource
I am getting this error when I pass an invalid SQL string... I spent the last hour trying to find the problem assuming - It's not my SQL it must be the db handle... ANyway, I've now figured out that it was bad SQL... 当我传递无效的SQL字符串时出现此错误...我花了最后一个小时尝试查找问题,假设是-不是我的SQL,它一定是db句柄...答:现在,我已经弄清楚了是糟糕的SQL ...
What I want to do is test the result of the mysql_query() for a valid resultset. 我想要做的是测试mysql_query()的结果是否为有效的结果集。
I am simply using empty($result)... Is this the most effective test? 我只是在使用empty($ result)...这是最有效的测试吗? Is there a more widely accepted method of testing a resultset for a valid result?
有没有更广泛接受的方法来测试结果集的有效结果?
mysql_query
will return false
if there is an error 如果有错误,
mysql_query
将返回false
$result = mysql_query('select * from');
if ($result === false) {
// caused by my invalid input above
} else {
// process as usual
}
In fact, you're getting the error you describe because you're literally calling mysql_num_rows(false)
实际上,您得到的错误描述是因为您实际上是在调用
mysql_num_rows(false)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.