php - CI - show database error or fail -


i've developed simple login system works ok fails, , need know why

question: how show causing fail. not validation error error either data being passed mysql or query somehow failing

here's db function:

function login($email,$password) {     $this->db->where("email",$email);     $this->db->where("password",$password);      $query=$this->db->get("users");     if($query->num_rows()>0)     {         foreach($query->result() $rows)         {             //add data session             $newdata = array(                 'user_id'  => $rows->id,                 'user_name'  => $rows->username,                 'user_email'    => $rows->email,                 'logged_in'  => true,             );         }         $this->session->set_userdata($newdata);         return true;     }     return false; } 

and here's logic:

public function login() {     $this->load->library('form_validation');     // field name, error message, validation rules     $this->form_validation->set_rules('email', 'your email', 'trim|required|valid_email');     $this->form_validation->set_rules('password', 'password', 'trim|required|min_length[4]|max_length[32]');      if($this->form_validation->run() == false)     {         $this->signin();     }     else     {         $email=$this->input->post('email');         $password=md5($this->input->post('pass'));         $result=$this->user_model->login($email,$password);         if($result)         {             $this->dash();         }         else         {             $data['title']= 'login error';             $this->load->view('nav/header', $data);             $this->load->view('login', $data);             $this->load->view('nav/footer', $data);         }     } } 

i know error happening redirect login page if fail , change title text show me (only in testing mode right now) - how can find out going wrong query?

you can use log_message , check logs if y behave expected:

http://ellislab.com/codeigniter/user-guide/general/errors.html

i use echo '<pre>'; print_r($query->result());die; after $query formed. it's faster.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -