简体   繁体   English

mysql_num_rows():提供的参数不是有效的MySQL结果资源

[英]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.

相关问题 mysql_num_rows():提供的参数不是有效的MySQL结果资源 - mysql_num_rows(): supplied argument is not a valid MySQL result resource 警告mysql_num_rows():提供的参数不是有效的MySQL结果 - Warning mysql_num_rows(): supplied argument is not a valid MySQL result 警告:mysql_num_rows():提供的参数不是没有mysql_error()的有效MySQL结果资源 - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource with no mysql_error() 警告:mysql_num_rows():提供的参数不是有效的MySQL结果资源 - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource 如何解决mysql_num_rows():提供的参数不是PHP中的有效MySQL结果资源 - How to solve mysql_num_rows(): supplied argument is not a valid MySQL result resource in php 警告:mysql_num_rows():提供的参数不是有效的MySQL结果资源 - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource 警告:mysql_num_rows():提供的参数不是有效的MySQL结果资源nationalbuilder webhooks API - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource nationbuilder webhooks API mysql_num_rows():提供的参数在15中不是有效的MySQL结果资源 - mysql_num_rows(): supplied argument is not a valid MySQL result resource in 15 mysql_num_rows():提供的参数不是有效的MySQL结果资源(唯一) - mysql_num_rows(): supplied argument is not a valid MySQL result resource (unique) 修复错误:mysql_num_rows():提供的参数不是有效的MySQL结果资源 - Fixing the error: mysql_num_rows(): supplied argument is not a valid MySQL result resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM