Warning: MySQL_Num_Rows() Expects Parameter 1 to Be Resource, Boolean Given

ERROR: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\...\....php on line 19

Probably mysql_query() failed. In this case it returns false. Use mysql_error() to find out, what happens.

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given

That's because mysql_query sometimes returns boolean false (query error). You need to check it:

$amn = mysql_query("SELECT * FROM `Messages` WHERE to_user='$usr' AND read='0'");

if($amn === false) {
var_dump(mysql_error());
}
else {
print_r(mysql_num_rows($amn));
}

Code above is written in bad style and deprecated. Use PDO with Exceptions in real projects.

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /var/customers/webs/ni272979_1/Loader/login.php on line 17

You have an error in your query. It should be something like this.

$sql = "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword';";

And then you can do something like this.

 $result=mysql_query($sql) or die(mysql_error());

Also try using MySQLi or PDO function for CRUD operations.



Related Topics



Leave a reply



Submit