[英]problems with mysql_num_rows
for some reason i can not understand im having troubles with mysql_num_rows. 由于某种原因,我无法理解我在使用mysql_num_rows遇到麻烦。
Heres the script: 这是脚本:
$notquery = 'SELECT * FROM notification WHERE uid = 1 AND read = 0
AND tipo = post
OR tipo = subpost OR tipo = logros';
$notQuery = (mysql_query($notquery));
$num_rows = mysql_num_rows($notQuery);
error: 错误:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
This is probably because you have an error in the query execution. 这可能是因为查询执行中有错误。
Try adding or die(mysql_error())
to debug what's going wrong... 尝试添加
or die(mysql_error())
调试出了什么问题...
update the code to : 将代码更新为:
$notQuery = mysql_query($notquery) or die(mysql_error());
You input a string into mysql_num_rows
=) 您在
mysql_num_rows
=中输入一个字符串
You use $notquery
and $notQuery
mixed... That must be the silliest thing I've ever seen. 您将
$notquery
和$notQuery
混合使用...那一定是我见过的最$notQuery
的事情。
Try this: 尝试这个:
$sql = 'SELECT .....';
$result = mysql_query($sql);
echo mysql_error()."\n";
$numRows = mysql_num_rows($result);
Obviously, this might produce the same error, since you don't check for errors :) $result
might not be a MySQL resource (it might be FALSE
). 显然,这可能会产生相同的错误,因为您没有检查错误:)
$result
可能不是MySQL资源(可能是FALSE
)。
The sql is full with syntax error, try this sql充满语法错误,请尝试此
SELECT * FROM notification
WHERE
uid = 1 AND
`read` = 0 AND
tipo in('post', 'subpost', 'logros');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.