Error: Warning: MySQL_Num_Rows() Expects Parameter 1 to Be Resource, Boolean Given in C:\Xampp\Htdocs\...\....PHP on Line 19

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

mysql_num_rows causes an error message

Does this work?

<?php
$con = mysql_connect("aaa", "bbb", "ccc", "ddd");
mysql_select_db("database", $con);
$sql = "SELECT * FROM list";
$result = mysql_query($sql,$con);
echo mysql_num_rows($result);
?>

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in...' but my query is correct


$query = "SELECT * FROM newuser WHERE token='$token'";
$result = mysql_query($query) or die(mysql_error());

while($row=mysql_fetch_array($result)) {
do stuff...
}

If the die statement is not executed, $result is OK when you enter the while loop. The problem then is probably that you use $result for a query inside the loop as well, eventually leading to it being set to false.



Related Topics



Leave a reply



Submit