php - Undefined index: sUS_UserID -


this question has answer here:

i need php. error:

notice: undefined index: sus_userid in c:\xampp\htdocs\fazebook\inc\class.user.php on line 21

my "error" code:

$userloginq = $db->query("select * `users` `userid` = '{$_cookie["sus_userid"]}'"); // line 21 if (intval($db->num($userloginq)) > 0) {     $userlogina = $db->arr($userloginq);     if ($_cookie["sus_userid"] == $userlogina["userid"]) {         if ($_cookie["sus_security"] == md5($userlogina["lastip"])) {             if ($_cookie["sus_password"] == md5($userlogina["password"])) {                 $this->id       = (int) $userlogina["userid"];                 $this->name     = $userlogina["username"];                 $this->loggedin = true;             }         }     } } 

you need ensure cookie exists , named 'sus_userid'. error message received seems indicate not have cookie defined name.

for clarity sake, may wish consider changing way interpolate $_cookie data. not required, may improve code clarity , syntax highlighting, , may avoid difficult-to-find quoting errors.

$userloginq = $db->query("select * `users` `userid` = '" . $_cookie['sus_userid'] . "'"); 

finally, consider reading on sql injection vulnerabilities. cookies user-editable, , using unsanitized user content in sql queries can put data @ risk.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -