我只是在PHP中的新手,我需要創建一個PHP登錄形式,但它有一個語法錯誤說Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\login.php on line 18
也許你可以幫我在這TNX!PHP選擇登錄錯誤
<?php
$con=mysqli_connect("localhost","root","","reservation");
if (mysqli_connect_errno())
{
echo "Failed to connect to Database: " . mysqli_connect_error();
}
else
{
}
if ($_POST["SUBMIT"]="SUBMIT")
{
$username = $_POST['username'];
$password =$_POST['password'];
$sql ="SELECT * FROM usersaccount where='$username' and password ='$password'";
$result=mysqli_query($con,$sql);
$count=mysqli_num_rows($result);
if($count==1)
{
echo "success";
}
//mysqli_close($con);
}
?>
'「SELECT * FROM usersaccount =‘$用戶名’和密碼='$密碼'「'???錯過了'where' –
你在查詢時需要檢查錯誤,然後嘗試使用'$ result'。如果你這樣做了,你會被告知你的查詢語法錯誤。 – Barmar
您的代碼容易受到SQL注入的影響。 – Gumbo