John Stimac
John Stimac

Reputation: 5493

mysql num rows is failing

$result=mysql_query("SELECT * FROM users WHERE pass='".sha1($_POST['mainloginpass'])."'");

if(mysql_num_rows($result)==1){

it says that "mysql_num_rows() expects parameter 1 to be resource, boolean given"

Upvotes: 1

Views: 266

Answers (1)

Nick Presta
Nick Presta

Reputation: 28665

mysql_query normally returns a resource, but according to the docs:
mysql_query() will return FALSE on error and also fail and return FALSE if the user does not have permission to access the table(s) referenced by the query.

You may want to try something like this:

if (!$result) {
    die('Invalid query: ' . mysql_error());
}

To see what the problem is.

Upvotes: 4

Related Questions