This is my foreach loop, and it has worked great for me so far until now. My problem with this bit of code is that when I don't have a row in the database it gives an error like this....
I'm sure there is more then one way to fix this problem.
How can I prevent this error???
$sql = "SELECT * FROM database WHERE name = \"$name\"
";
$result = @mysql_query($sql,$conn) or die(mysql_error());;
while
($forow=@mysql_fetch_assoc($result)){
$name[] = $row['name'];
}
@mysql_free_result($result) or die();
foreach ($name as $f)
{
echo "$f";
}
Warning: Invalid argument supplied for foreach() in
/www/site.com/web/main.php on line ###
I'm sure there is more then one way to fix this problem.
How can I prevent this error???
$sql = "SELECT * FROM database WHERE name = \"$name\"
";
$result = @mysql_query($sql,$conn) or die(mysql_error());;
while
($forow=@mysql_fetch_assoc($result)){
$name[] = $row['name'];
}
@mysql_free_result($result) or die();
foreach ($name as $f)
{
echo "$f";
}
