php - Call to a member function where() on a non-object -
i'm developing website using codeigniter. when open page error :

i haven't encountered problem before, , know have in every controller uses database library.
this example of function in model error :
public function login($pseudo,$password) { $this->db->where("pseudo",$pseudo); $this->db->where("password",$password); $query=$this->db->get("admin"); if($query->num_rows()>0) { foreach($query->result() $rows) { //add data session $newdata = array( 'admin_id' => $rows->id, 'admin_pseudo' => $rows->pseudo, 'admin_fullname' => $rows->fullname, 'admin_email' => $rows->email, 'admin_logged_in' => true, ); } $this->session->set_userdata($newdata); return true; } return false; } the line 13 : $this->db->where("pseudo",$pseudo);
this controller :
public function login() { $this->load->library('form_validation'); $this->form_validation->set_rules('login', 'pseudo', 'trim|required|min_length[4]|max_length[32]'); $this->form_validation->set_rules('password', 'password', 'trim|required|min_length[4]|max_length[32]'); $pseudo=$this->input->post('login'); $password=md5($this->input->post('password')); $result=$this->admin_model->login($pseudo,$password); if($this->form_validation->run() == false) { $this->index(); } else { if ($result) $this->dashboard(); else $this->index(); } } in autoload file have :
$autoload['libraries'] = array('database','session');
$this->db not object apparently. check it's initialized before calling login()
Comments
Post a Comment