Hello all,
I've been surfing forum threads on this, and there are plenty, with no satisfactory results. Here's the deal...
I've got quite a few instances of this very common query code on my site:
//example 1
$result = mysql_query("SELECT * FROM table WHERE ID = ".$_REQUEST['ID']."");
$row = mysql_fetch_array($result); //LINE OF CODE IN ERROR
//example 2
$result = mysql_query("SELECT * FROM table WHERE ID = ".$_REQUEST['ID']."");
while($row = mysql_fetch_array($result)) { //LINE OF CODE IN ERROR
//LOOP DATA
}
The PHP error log will frequently give a warning to this effect:"PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/ftp/path/to/file.php on line 15".
The important thing to know is that I ALWAYS get the desired result from the database. I've added "or die(mysql_error())" to the end of the queries with no error being displayed and echoing the $result will always give me the resource id number.
If I'm getting the data, why would there be a warning? Most of the diagnoses of this error in these forum threads I've been reading keep mentioning bad queries or database connections. Apparently, neither of those things are the problem if I'm actually getting results.
Enlightenment?