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

Recommended Answers

All 2 Replies

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

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.

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.