CodeIgniter Forums
undefined variable in view - 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: undefined variable in view (/showthread.php?tid=48863)



undefined variable in view - El Forum - 01-31-2012

[eluser]Unknown[/eluser]
I load view in a controller and pass an array of data to it. When use this data as variables in a view php tells that all of them are undefined.
I tried to google but code seems to be corrent. What is wrong?

controller code:
Code:
public function index()
{
  $this->sitesessions->set_session_id($this->session->userdata('session_id'));
  $user_id = $this->sitesessions->check();
  
  $logon = false;
  if ($user_id == false)
   $logon = true;
  
  $data['logon'] = true;
  
  $this->load->view('header', $data);
  $this->load->view('news');
  $this->load->view('footer');
}
view code:
Code:
<div>
&lt;?php
  if ($logon == false) echo "You are not authorized. " . anchor('login', 'Login');
  else echo "Welcome."; ?&gt;.
    <div>
Thanks.


undefined variable in view - El Forum - 01-31-2012

[eluser]Unknown[/eluser]
Ok, I've found answer. There was an error in a model. But php said nothing about earlier, maybe the page was cached.