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

code:

$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?

Thanks

Recommended Answers

All 2 Replies

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());

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.