joshgarrod Posted June 15, 2009 Share Posted June 15, 2009 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 { } } } ?> Link to comment https://forums.phpfreaks.com/topic/162216-solved-list-of-blog-comments-not-displaying/ Share on other sites More sharing options...
Jibberish Posted June 15, 2009 Share Posted June 15, 2009 You need to select the database <?php mysql_select_db($db, $cid); ?> and also with the mysql query you need to pass the link through as well (I think) <?php $query = mysql_query("SELECT * FROM comments ORDER BY ref", $cid); ?> Link to comment https://forums.phpfreaks.com/topic/162216-solved-list-of-blog-comments-not-displaying/#findComment-856081 Share on other sites More sharing options...
joshgarrod Posted June 15, 2009 Author Share Posted June 15, 2009 Nice one thanks, I missed that. Link to comment https://forums.phpfreaks.com/topic/162216-solved-list-of-blog-comments-not-displaying/#findComment-856087 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.