PDA

View Full Version : mysql_num_rows() expects parameter 1 to be resource


el3reef
05-27-2014, 12:41 AM
Hello,

i'm using query like that

$result = mysql_query("SELECT * FROM workshop_months_records where month_date LIKE '$month_date' limit 1");
$result_num_row = mysql_num_rows($result);

and this error return to me

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in ..../includes/class_postbit.php(289) : eval()'d code on line 103

Although the plugin was work perfectly on version 3

waiting for help

thanks :)

kh99
05-27-2014, 08:02 AM
I guess that would happen if the query failed. Change the code to something like:
$result = mysql_query("SELECT * FROM workshop_months_records where month_date LIKE '$month_date' limit 1");
if ($result)
{
$result_num_row = mysql_num_rows($result);
// etc
}


and see if the error goes away. I don't see anything wrong with the SQL, but it woul depend on the database including that table, and having $month_date set.

tbworld
05-27-2014, 07:41 PM
At least that masks the initial error, but you are right @kh99, there was always a chance that the query could return a Boolean. :)

kh99
05-27-2014, 08:43 PM
Yeah, you're right, I should have been more clear in saying that my "fix" is really only testing for FALSE to avoid the error, but doesn't fix the problem.

el3reef
05-27-2014, 10:44 PM
the code work without problems in version 3 , and this error show white mysqli not mysql , so I expect that version 3 developed with mysqli , mysql_num_rows(); need $link parameter puls $result parameter , so i don't know how i can count the count of rows without the second parameter

--------------- Added 1401234837 at 1401234837 ---------------

i will tray $result = mysql_query("SELECT COUNT(*)
i hope it work