0
$result = mysql_query("SELECT * FROM Users") or die("could not select ".mysql_error());
if (!$result) {
		   	echo 'Could not run query: ' . mysql_error();
				}
				
				$rows = mysql_num_rows($result) or die("no rows" . mysql_error());
				if ($rows > 0) {
				$row = mysql_fetch_assoc($result);	
				    while ($row = mysql_fetch_assoc($result)) {
			        print_r($row);
			    }

Every time I run this, I get the error "no rows" from the die statement, but I tested the sql and it runs correctly. The num rows is not working.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rainhider
0

Your syntax is incorrect.

Try this:

if (mysql_num_rows($result) > 0) {
  $row = mysql_fetch_assoc($result);	
  while ($row = mysql_fetch_assoc($result)) {
    print_r($row);
  }
}

Edited by Will Gresham: n/a

0

I had switched to an apache server and it had been given me issues. The code works fine on my original server so i am just going to host the site on my current hosting company.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.