CodeIgniter Forums
One problem with PHP 5.4.7 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: One problem with PHP 5.4.7 (/showthread.php?tid=56067)



One problem with PHP 5.4.7 - El Forum - 11-24-2012

[eluser]sarbaz[/eluser]
Hi
One problem with PHP 5.4.7


Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: row

Filename: core/Loader.php(829) : eval()'d code

Line Number: 6


Code:
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: core/Loader.php(829) : eval()'d code

Line Number: 6


Code:
<?php
  foreach ($test as $i) {
   echo ($i);
  }
?>

What could be the reason for the error?????


One problem with PHP 5.4.7 - El Forum - 11-24-2012

[eluser]hungryhippo[/eluser]
Can you post the code from your controller and view?


One problem with PHP 5.4.7 - El Forum - 11-24-2012

[eluser]sarbaz[/eluser]
Controller
Code:
public function index(){
       $data['article'] = $this->model_article->IndexArticleList();
         $this->_out('contain',$data);

}

View
Code:
<? foreach($article as $row):?>
<div class="ContainTitle"><a href="&lt;?=base_url();?&gt;site/summary/&lt;?=$row-&gt;id?&gt;">&lt;?=$row->title?&gt;</a></div>
        <div class="article">
         &lt;?=$row->summary?&gt;
        </div>
        <div>/div>
&lt;? endforeach ?&gt;

Model
Code:
public function IndexArticleList(){
$count = $this->uri->segment(3);
          $this->db->order_by("id", "desc");
          $this->db->limit(5,$count);
          $this->db->where('archive','0');
$data = $this->db->get('nik_article');
return $data->result();
}