CodeIgniter Forums
condition check failure - 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: condition check failure (/showthread.php?tid=23343)



condition check failure - El Forum - 10-07-2009

[eluser]agubski[/eluser]
after a cup of coffee the same code just stopped messing around. Must be miracle Smile

Hi there,

I have a simple if - then condition which fails and I can't see what the problem is. here is the code:
Code:
function displayuser()
    {

    $query = $this->db->get_where('users', array('user-email' =>$_POST['e-mail']));
                
    if ($query->num_rows() == 0) {    
            
         echo "user doesn't exist" ;
            
            
    } elseif ($query->row()->password == $_POST['password']){
        
      echo "All is good" ;
            
    }else{
        
    echo "password doesn't match for this user";
            
    }    
                    
}

PHP error I see is - Trying to get property of non-object in "elseif" line

I think the elseif check shouldn't go ahead if the first condition is met. However it seems like the code is trying to run this line anyways and obviously there is no variable to test...

Appreciate your ideas


condition check failure - El Forum - 10-07-2009

[eluser]Colin Williams[/eluser]
Are you sure you're running PHP 5?