![]() |
cannot use mysql_fetch_array no error
I am trying to echo out the resultset but I just get the text error:
"Can't use resultset" from the die command (in bold below) Any ideas what could be wrong? Code:
<?php |
Are you sure there isn't an error after the "Can't use resultset" text? Does your query return results when you run it directly (phpMyAdmin, HeidiSQL, etc)?
|
Quote:
The SQL runs find in phpmyadmin the page source prints this, which doesn't make any sense because it is supposed to have exited when it hit the die command Code:
|
Fixed it.
I took out the die command from the while section as it can't go there. Also, I renamed the columns to use an AS name as it cannot pick up rows with ambiguous column names. |
or die() can only be used where you could test for a boolean but haven't used an if ().
In your case, $result = mysql_query($query) or die(mysql_error()); would return either false or a non false result so or die() will work correctly. while () does not return a result. Therefore using or die() could never work properly there. |
| All times are GMT +1. The time now is 03:47 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.