Click to See Complete Forum and Search --> : Code Not Working!


Dysan
11-23-2007, 11:05 AM
Why do I get the following error message, when output items from the database?

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\User\Desktop\Xampp\htdocs\1.php on line 17

foreach($array as $item)
{
$result = mysql_query("SELECT * FROM names WHERE id = '$id'");
while($row = mysql_fetch_array($result)) //This is line 17
{
$row['Firstname']." - ". $row['Surname'] ." ".$row['Sex'];
}
}

MrCoder
11-23-2007, 11:11 AM
foreach($array as $item)
{
$result = mysql_query("SELECT * FROM names WHERE id = '$id'") or die(mysql_error());
while($row = mysql_fetch_array($result)) //This is line 17
{
$row['Firstname']." - ". $row['Surname'] ." ".$row['Sex'];
}
}


Change your to match the above and re-run it to see the error..

Where is "$id" set?