2016-04-05 130 views
-2
if(mysqli_num_rows($result) > 0) 
$user_name = "123"; 
$user_password = "123"; 
$mysql_qry = "SELECT * FROM employee_data WHERE username like '$user_name' and password '$user_password' "; 
$result = mysqli_query($conn,$mysql_qry); 
if(mysqli_num_rows($result) > 0) 
    echo "login success"; 
else 
    echo "login not success"; 

我試圖用幾種方法解決這個問題,但我不知道問題出在哪裏 - 就像在視頻中看到的那樣。mysqli登錄檢查失敗

一切似乎都很好,但我不知道爲什麼它不起作用。以下是錯誤消息的屏幕截圖:

help me where is the problem

+0

你的問題是'密碼'$ user_password'',因爲沒有操作符,將其替換爲:'password ='$ user_password''。但代碼也有其他問題。 – Nergal

回答

0

查詢失敗,因爲有一個=and password '$user_password'失蹤。結果是,$result不是一個對象。這讓mysqli_num_rows失敗