PHP - Undefined variable

后端 未结 9 748
星月不相逢
星月不相逢 2021-01-26 05:29

I\'m doing some exercises from Beginners PHP & MySQL by Mr. Tucker.

On his example everything works fine, but on my PC there is an error:

9条回答
  •  野的像风
    2021-01-26 05:46

    while ($row = mysql_fetch_array($tUser_SQLselect_Query, MYSQL_ASSOC)) {
      $passwordRetrieved = $row['password'];
    }
    

    this is the only place where a value may be assigned to the variable $passwordRetrieved.
    If there is no record in the result set the body of the while-loop is never executed and therefore no value ever is assigned to $passwordRetrieved and therefore $passwordRetrieved does not exist/is undefined at line 39 -> Notice: Undefined variable: passwordRetrieved in C:\wamp\www\loginForm.php on line 39.

提交回复
热议问题