I try to write a site with CodeIgniter but I’ve a problem with PHP. I’m sure that it’s so simple and can’t be wrong. But I don’t know bugs from , just a newbie of CodeIgniter 🙂
<html>
<head>
<title><?=$page_title?></title>
</head>
<body>
<?php foreach($result as $row):?>
<h3><? echo $row->title; ?></h3>
<p><? echo $row->text; ?></p>
<?php endforeach;?>
</body>
</html>
I’ve a bug from this file :
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for
foreach()Filename: views/helloworld_view.php
Line Number: 6
thanks in advance for reading this 🙂
The variable you supply to the foreach loop has to be an array. You can skip the foreach if the value of the variable supplied is not an array with the solution below.