function get_total_urls(){
$total = mysql_query("SELECT COUNT('url_key' FROM 'urls')");
$url_total = mysql_result($total, 0);
echo $url_total;
}
returns error:
Warning: mysql_num_rows() expects parameter 1 to be resource
I have been browsing to find the cause, most people get it due to the lack of mysql_query but I’m using that.
Any ideas where I’m going wrong? I know the database information is correct.
Thanks.
Your query is failing. Therefore,
$totalis receivingfalseinstead of the MySQL resource. Hence the error.This is because you are using single quotes instead of back ticks (or nothing) and an incorrect syntax for
COUNT().Note: When in doubt, run your query directly against MySQL (from CLI or PHPMyAdmin) or use
mysql_error().