我目前正在使用用戶和密碼錶訪問mysql數據庫的登錄頁面。每當我嘗試運行我的代碼,我得到以下錯誤無論怎樣我的評論:在登錄頁面出現奇怪的PHP錯誤
Parse error: syntax error, unexpected '=', expecting ',' or ';' in /home/scs/licenta/an2/gr927/rpie1814/public_html/testphpathome/login.php on line 15
這裏是HTML主頁:
<!DOCTYPE html>
<html>
<head>
<title>
Gaming site
</title>
</head>
<body>
<h1>
Log-In
</h1>
<form action="login.php" method="post">
Username: <br>
<input type="text" name="user"> <br>
Password: <br>
<input type="text" name="pass"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
這裏是PHP代碼:
<?php
$user = $_POST["user"];
$pass = $_POST["pass"];
global $conn = mysqli_connect("localhost", "rpie1814", "rpie1814", "rpie1814");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM Users";
global $result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 1)
{
header("Location: /game.php");
exit;
}
else
{
echo "Unknown user";
}
mysqli_close($conn);
exit;
?>
從連接中刪除'global'並得到結果 – Saty
@replace'$ connect'用'$ con' – Iceman
嘿爲什麼你使用了全局單詞。任何特定的原因????? – user1234