扔真的,我有一些代碼和connat圖的一個問題,爲什麼它會錯PHP/mysqli的每一次
//Searches the database for the username
$mysqli_username = mysqli_query($mysqli, "SELECT username FROM ajbs_users WHERE username=`".$username."`");
// if name does not exist
if ($mysqli_username == null)
{
echo "<p>Username was inccorect, or user does not exist</p>";
}
else //if username is correct
{
//finds and stores password of the user
$mysqli_userPassword = mysqli_query($mysqli, "SELECT password FROM ajbs_users WHERE password=`".$password."`");
if ($mysqli_userPassword != $password) //checks password matches from user
{
echo "<p>Password was inccorrect</p>";
}
else
{
//Login
echo "<p>You have been logged in";
// Re directs to other page after creating a session
}
}
腳本保持輸出「密碼不正確」的聲明。
**請在使用前閱讀功能說明。它只需幾個按鍵即可:php.net/mysqli_query –
'$ mysqli_userPassword'包含一個MySQL資源,**不是字符串**。你正在比較一個結果對象和一個字符串,並且比較總是評估爲'FALSE'。 –
更不用說所有的徒勞掙扎 - 任何人都可以不用密碼登錄 –