I was doing some php; I found that the following code works
function get_total_urls() {
$total = mysql_query('SELECT COUNT(`url_key`) FROM `urls`');
return (int)mysql_result($total, 0);
}
get_total_urls();
But following code shows warning
function get_total_urls() {
$total = mysql_query("SELECT COUNT('url_key') FROM 'urls'");
return (int)mysql_result($total, 0);
}
get_total_urls();
Shows the following warning:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given.
Please help; why the 2nd code shows warning but 1st code is ok? The 2nd code fails to get the count of 'url_key' from database table.
Is there anyway to write the first code without back-tick and it will work perfectly?