Code:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource
...tells you everything you need to know.
look at your mysql_fetch_array() call: the "supplied argument" is $result. PHP says $result is not a valid result resource.
So, what is it? $result came from mysql_query(), a few lines above. PHP says mysql_query() returns a result resource, or "FALSE on error". So, if $result is not a resource, then it's FALSE, and that means there was an error in your query.
Check the result before trying to use it:
PHP Code:
<?php
$con = mysql_connect("localhost","mysite_test","test1");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM test_members");
// check $result :
if(!$result){ die( mysql_error() ); }
// (...but never use die() in your production error handling.
// it's fine for development, but _not_ live sites.)
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'];
echo "<br />";
}
?>
Bookmarks