CodeIgniter Forums
array_key_exists expects parameter 2 to be array null given in CI3 Auth Class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: array_key_exists expects parameter 2 to be array null given in CI3 Auth Class (/showthread.php?tid=62390)



array_key_exists expects parameter 2 to be array null given in CI3 Auth Class - sid_ - 07-08-2015

Hi,

I've just updated a site to CI3 and am receiving the above error related to the following code snippet:
PHP Code:
// Get user from database
        
$user $CI->users->get(array("screen_name" => $attempt["screen_name"]));

        if (!
array_key_exists("password"$user)) {
            return 
null;
        } 

This originally returned false but changed to null after reading the CI3 Upgrade Documentation. What would be the most optimal way to solve this error?


RE: array_key_exists expects parameter 2 to be array null given in CI3 Auth Class - skunkbad - 07-08-2015

If ( is_null( $user ) OR ! array_key_exists("password", $user ) )