It's possible that:
You don't have an active database connection
The query result does not yield anything (ie the response is NULL) or
There is a syntax error in your query
I would use a program like Toad (Windows) or Sequel Pro (Mac OS) or good ol' terminal to check that your query yields a result.
If you are using something like a sprintf() to assemble your query from variable, ensure that you are getting the proper string output with an echo.
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
Check that the query string (SELECT id, name FROM mytable) works externally
eg. echo $query = sprintf("SELECT id, name FROM mytable WHERE id = %d",$var);
if echo $query yields something like:
[GOOD]: SELECT id, name FROM mytable WHERE id = 5
else
[BAD]: SELECT id, name FROM mytable WHERE id =
If the outputs well, then the rest should work just fine. Unless of course you don't have access to a database.
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
printf("ID: %s Name: %s", $row[0], $row[1]);
}