Far Cry Posted June 27, 2010 Share Posted June 27, 2010 Please help me fix this error thanks in advance I get this error Invalid argument supplied for foreach() in /home/latestne/public_html/tests/PHP Tests/article.php on line 25 <?php require_once("functions.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Articles</title> </head> <body> <div style="border:1px solid #dbdbdb; padding:10px; margin:10px;"> <?php //Shows all the articles. showAllArticles(); ?> </div> <div style="border:1px solid #dbdbdb; padding:10px;margin:10px;"> <?php //$id stores the xx got from the URL article.php?id=xx $id=$_GET['id']; //checks whether $id is active i.e whether article.php?id= some value or not if(isset($id)) { $info = getArticle($id); foreach($info as $key) { echo '<h1>'.$key["articleTitle"].'</h1>'; echo '<p>'.$key['articleContent'].'</p><br /><br />'; } } else echo "No article selected"; ?> </div> <div > <a href="insertarticle.php">Add New</a><br /> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/205997-invalid-argument-supplied-for-foreach/ Share on other sites More sharing options...
Mchl Posted June 27, 2010 Share Posted June 27, 2010 Where does $info come from? Check if it's an array (or object). var_dump($info); Link to comment https://forums.phpfreaks.com/topic/205997-invalid-argument-supplied-for-foreach/#findComment-1077912 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.