开发者

Why does mysql_num_rows($result) return 1 even if $result returns empty result set?

Why does mysql_num_rows($result) return 1 even if $result returns empty result set?

$resut=mysql_query("select * from tablename where column1='$memberid' and (TIME_TO_SEC(TIMEDIFF(NOW(),when_submit))/60<2)")or die开发者_如何学JAVA(mysql_error());
$count=mysql_num_rows($result);

when I echo $count, I get

1

.


You have a spelling error in your code. You store the result of the call to mysql_query() in the variable called $resut. That should be $result, since that is what you are passing in the call to mysql_num_rows()


You are obviously running 2 queries on the same page. I would advise returning them to different $result variables. $result1, $result2 if need be. In the past I've had instances where the $result did not get updated even though there wasn't a spelling issue (though I can't remember the cause).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜