Welcome Guest, Not a member yet? Register   Sign In
undefined variable in view
#1

[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.
#2

[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.




Theme © iAndrew 2016 - Forum software by © MyBB