Jump to content

Invalid argument supplied for foreach()


Far Cry

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.