Welcome Guest, Not a member yet? Register   Sign In
Data not passing from controller to view
#1

[eluser]mpar612[/eluser]
Hi everyone, I have done this dozens of times and am totally stumped as to why it isn't working.

For some reason the $data from my controller is not being made available to my view. If I do print_r($data) in my controller, it returns all of the data appropriately. If I access $artist in my view I get an error - Undefined variable: data

I am still pretty new to Codeigniter. Any thoughts or suggestions on places to start looking? Thanks!

I have this function in my controller:
Code:
public function view($slug)
{
  
  $data['artist'] = $this->artist_model->get_artist($slug);

  if(empty($data['artist']))
  {
   show_404();
  }

  $this->load->view('artists/view', $data);
  
}

I have this function in my model:
Code:
public function get_artist($slug = FALSE)
{
  if($slug === FALSE)
  {
   $query = $this->db->get('artists');
   return $query->result_array();
  }
  
  $query = $this->db->get_where('artists', array('slug' => $slug));
  return $query->row_array();
}


Messages In This Thread
Data not passing from controller to view - by El Forum - 05-05-2013, 07:06 PM
Data not passing from controller to view - by El Forum - 05-06-2013, 06:02 AM
Data not passing from controller to view - by El Forum - 05-06-2013, 07:57 AM
Data not passing from controller to view - by El Forum - 05-06-2013, 09:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB