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

mysql_num_rows() expects parameter 1 to be resource error, appeared in LogCat

you are mixing mysql with mysqli .

change this

  if (mysql_num_rows($result) > 0) 

to

 if (mysqli_num_rows($result) > 0) 

mysql_num_rows() expects parameter 1 to be resource for count row

Try this :

$carikomoditas=$_POST['cari'];
$cariquery=mysqli_query($connect,"select*from komoditassample where id='$carikomoditas'") or die('Error');
$res=mysqli_num_rows($cariquery); // result set

$data=mysqli_fetch_array($cariquery);

echo $res;

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 expects parameter 1 to be resource error when querying

I believe that because you are using mysqli_connect that you need to use the mysqli_query($conn,$sql) notation.

Try this:

$result = mysqli_query($conn,$sql)
if(mysqli_num_rows($result) > 0)

PHP warning expects parameter 1 to be resource, object given

Change:
mysql_fetch_assoc to mysqli_fetch_assoc

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

mysql_num_rows function accept resource identifier

in your case it is $query Note that $result1 is the fetched array and contain the data from database that should not be passed in this function.

mysql_num_rows($query)

And I would suggest you read the manual before asking quesions

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.



Related Topics



Leave a reply



Submit