Jump to content

[SOLVED] List of Blog comments not displaying


joshgarrod

Recommended Posts

Hi, I am trying to create a page that list comments that have been submitted about articles in my blog. The list is for the admin side so that he / she can send them live or delete them. However, for some reason they won't even display. The warning I am getting and my code is below. Thanks in advance

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Users\website\accept_decline_comments.php on line 56

 

<?php

			error_reporting (E_ALL ^ E_NOTICE);
    $usr = "usr";
    $pwd = "pwd";
    $db = "quest";
    $host = "host";

    # connect to database
    $cid = mysql_connect($host,$usr,$pwd);
    if (!$cid) { echo("ERROR: " . mysql_error() . "\n");    }

			$query = mysql_query("SELECT * FROM comments ORDER BY ref");	

			   if(mysql_num_rows($query)==0){

				echo "<p>There are currently no new comments</p>";

				  }else{

					while($info = mysql_fetch_array($query)){

					$ref = $info ['ref'];						
					$comment = $info ['comment'];
					$name = $info ['name'];
					$submitted = $info ['submitted'];
					$live = $info ['live'];

					if ($live == "No") {

					echo "<p>Comment by - $name on $submitted</p>
					<p>$comment</p>
					<p><a href=\"accept_comment.php?ref=$ref\">Go live</a> | <a href=\"delete_comment.php?ref=$ref\">Remove</a></p>
					<hr class=\"hr\" width=90%>";
					}
					else {
					}
					}
					}
			?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.