简体   繁体   中英

Trying to access array offset on value of type null…in login details

if ($row['email'] == $email && $row['password'] == $password) { 
  echo "Login success Welcome".$row['username']; # code... 
} 
else{ 
  echo "failed to login"; 
}

You can check if(!is_null($row)) along with the other checks, or simply:

if( $row && $row['email']==$email && $row['password']==$password ) { ... };

This happens when you query your DB, and there is no match, so there's no result, so the result is empty/null.. which you seem not to be checking within your code..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM