Steven
Steven

Reputation: 25304

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(mysql_error());
$count=mysql_num_rows($result);

when I echo $count, I get

1

.

Upvotes: 1

Views: 2149

Answers (2)

MindStalker
MindStalker

Reputation: 14864

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).

Upvotes: 0

Roland Bouman
Roland Bouman

Reputation: 31981

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()

Upvotes: 5

Related Questions