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
Calling Function Inside Preg_Replace Thats Inside a Function
How to Read Gzip-Ed Response from Stackoverflow API in PHP
Using PHP to Execute Multiple MySQL Queries
PHP Variable Inside Echo 'HTML Code'
Replace Woocommerce_Add_Order_Item_Meta Hook in Woocommerce 3.4
Reverse the Letters in Each Word of a String
Simple PHP SQL Login Troubleshooting
Calling Stored Procedure with Out Parameter Using Pdo
How to Count Query Result Rows
Syntax Error While Defining an Array as a Property of a Class
Variable Position in Comparision in PHP
Laravel Eloquent, Group by Month/Year
How to Change PHP's Eregi to Preg_Match
PHP & Sessions: How to Disable PHP Session Locking
Handling Plupload's Chunked Uploads on the Server-Side