Hello, Can anyone help me on this problem? I'm getting this error (see title) and i'm sure that my query works fine cause i even tried it in phpmyadmin and this works very well in my local machine but when uploaded in my domain I already get that error. Any ideas? Thanks in advance!
$query = mysql_query("SELECT * FROM table") or die(mysql_error()); while ($data = mysql_fetch_array($query)) { // data processing goes here } PHP: This should work.
This function works when there is at least 1 result. In other words, in your query there is no result. One more thing, please remember to put ` ` at the start and end of every table name. Your query must be: $query = mysql_query("SELECT * FROM `table`") or die(mysql_error()); while ($data = mysql_fetch_array($query)) { // data processing goes here } PHP:
Your query may return an empty result. To fix this, you need to check if the $query return false or empty: $query = mysql_query("SELECT * FROM `table`"); if (!$query or mysql_num_rows($query)) { echo "Empty"; } else { while ($data = mysql_fetch_array($query)) { // data processing goes here } }