Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”
I'm trying to pass both session data and a db query to a view in Codeigniter. I get an error in my view file that says: 'Message: Undefined variable: data'
The problem lies with in the $idea variable. The variables register an undefined error.
Controller:
public function members() {
if($this->session->userdata('is_logged_in')){
$session = $this->session->all_userdata();
$facebook_id = $data['id'];
$this->load->model('idea');
$idea = $this->idea->get_idea($facebook_id);
//merge the two arrays to get data variable
$data = $session + $idea;
$this->load->view('members', $data);
} else {
redirect('main/login');
}
}
Model:
public function get_idea($facebook_id) {
$data = array(
'id' => '',
'idea' => '',
'facebook_id' => $facebook_id
);
$query = $this->db->get('idea', $facebook_id);
return $query->result_array();
}
Here are some of the resources I've used:
-Creating foreach loops using Code Igniter controller and view
-codeigniter: pass array from controller to view
-http://blog.mattheufarmer.com/2010/building-a-website-in-codeigniter-part-ii-getting-data-and-using-it/
Thank you for the help!