Hi! I use a paginate feature on my website, it works great on the front page, but when I use it in the comment section I get this:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/56/6296656/html/comments.php on line 77


$query = "SELECT where headm='".$_GET['chead']."' AND COUNT(*) as num FROM $tableName";
	$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = $total_pages[num];

I tried adding the 'where' element into it, so it would only count those with that specific title...

'$query = "SELECT COUNT(*) as num FROM $tableName";' Gets every comment...

Why isn't the 'where' element working with it?


Where should be at the end:

$query = "SELECT COUNT(*) as num FROM $tableName  where headm='" . mysql_real_escape_string($_GET['chead']) . "'";

MySQL is the best database using with PHP main. I also use it with my PHP sites. One example to connect PHP to MYSQL,
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM example")
or die(mysql_error());