CodeIgniter Forums
Call to a member function row_array() on a non-object - 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: Call to a member function row_array() on a non-object (/showthread.php?tid=47822)



Call to a member function row_array() on a non-object - El Forum - 12-23-2011

[eluser]ibnclaudius[/eluser]
I got this error when trying to execute a foreach.

Fatal error: Call to a member function row_array() on a non-object in /home/brainflo/public_html/application/controllers/user.php on line 61

Code:
$data = array('email' => $this->security->sanitize_filename($this->input->post('email')),
          'password' => $this->encrypt->sha1($this->security->sanitize_filename($this->input->post('password'))),
     );
    
     $query = $this->Model->get($this->users_table, $data);
    
     if ($query) {

      $this->session->set_userdata('logged_in',TRUE);
      
      $userdata = $this->Model->get($this->users_table, $data);
      
      foreach ($userdata->row_array() as $fieldname => $fielddata) {
      
       $this->session->set_userdata($fieldname, $fielddata);
      
      }
      
      $this->session->unset_userdata('password');

      redirect('user/home', 'refresh');
      
     } else {
      
      //fail message
      
     }


Code:
public function get($table, $data) {
  
  $query = $this->db->get_where($table, $data);

  if ($query) {

   return $this->db->get_where($table, $data);
  
  } else {

   return FALSE;
  
  }

}