Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\\

Changed to Php5.3 and receiving these warning messages,

Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\wamp\www\050505\fnc2.php on line 322

I think it’s saying that ($sql_res) needs to be a resource and not a boolean on line 322.


function get_cat_count($ct)
{
// This function return how many ads exist in the specified category
global $cat_fields, $table_ads, $page, $adsonpage;

$sql_query=“select count(idnum) from $table_ads where
catname=‘$ct’ and visible=1”;

$sql_res=mysql_query(“$sql_query”);
$row=mysql_fetch_row($sql_res); // line 322
$count=$row[0];
return $count;
}

How do I create a resource from this boolean?
Thanks for your replies,:slight_smile:

It means that mysql_query isn’t returning a resource but instead returning false, meaning that there is an error in your sql code.

Use the following code and see what error you get:

$sql_res = mysql_query($sql_query) or die (mysql_error());

I included code on line 321 the above code and an now receiving the following message,:slight_smile:

you have an error in your SQL syntax;
check the menual that corresponds to your MySQL server version for the
right syntax to use near 'where catname=‘Elec’ and visible = 1’at line 1

You have an error in your SQL query.
Echo the query, and see if you can spot the error… which is just before the “WHERE” clause.