I am trying to execute a select query in CodeIgniter like below:
public function validate()
{
$username = $this->security->xss_clean($this->input->post('username'));
$password = $this->security->xss_clean($this->input->post('password1'));
$type = $this->security->xss_clean($this->input->post('utype'));
$password = md5($password);
$this->db->select('*');
$this->db->from('ci_users');
$this->db->where('email', $username);
$this->db->where('password', $password);
$this->db->where('utype', $type);
// Run the query
$query = $this->db->get();
// Let's check if there are any results
if($query->num_rows == 1)
{
// more scripting
} else {
echo "OOPS some error";
}
}
It is always showing oops some error, even I am enter correct username and password. why select query not run? I have done something wrong.
You are used :
if($query->num_rows == 1)
Correction is like bellow :
if($query->num_rows() == 1)