salman_ahad@yahoo.com Posted October 25, 2009 Share Posted October 25, 2009 require_once("includes/connection.php"); $query = mysql_query("SELECT * FROM users ORDER BY id DESC"); $num_rows = mysql_num_rows($query); if ($num_rows < 1) { echo "No comments posted yet"; } else { while($row = mysql_fetch_array($query)) { $userid = $row['userid']; $username = $row['usernm']; $userpassword = $row['userpw']; echo "$userid"; echo "$username"; echo "$userpassword"; echo "<br \>"; } } My error --------- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource. It has returned me empty but my database has data..What did I do wrong? Quote Link to comment Share on other sites More sharing options...
kickstart Posted October 25, 2009 Share Posted October 25, 2009 Hi Put or die(mysql_error()); on the end of the line $query = mysql_query("SELECT * FROM users ORDER BY id DESC"); All the best Keith Quote Link to comment Share on other sites More sharing options...
salman_ahad@yahoo.com Posted October 25, 2009 Author Share Posted October 25, 2009 Now I am getting Unknown column 'id' in 'order clause' error Quote Link to comment Share on other sites More sharing options...
kickstart Posted October 25, 2009 Share Posted October 25, 2009 Hi It is saying that table users does not have a column called id in it. All the best Keith Quote Link to comment Share on other sites More sharing options...
salman_ahad@yahoo.com Posted October 25, 2009 Author Share Posted October 25, 2009 Thanks Keith, I was using a different 'id'...I fixed it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.