代码问题 - 意外 $end ?现在尝试了半个小时来解决这个问题....
你能发现问题吗?
<?php
session_start();
if (!isset($_SESSION['user_id'])) {
if (isset($_COOKIE['user_id']) && isset($_COOKIE['username'])) {
$_SESSION['user_id'] = $_COOKIE['user_id'];
$_SESSION['username'] = $_COOKIE['username'];
}
}
?>
<html>
<head>
</head>
<body>
test
<?php
$dbc = mysqli_connect(localhost, hidden, hidden, hidden);
if (!isset($_GET['shipID'])) {
$query = "SELECT user_id, shipID, IP, Image FROM ships WHERE shipID = '" . $_SESSION['shipID'] . "'";
}
else {
$query = "SELECT user_id, shipID, IP, Image FROM ships WHERE shipID = '" . $_GET['shipID'] . "'";
}
$data = mysqli_query($dbc, $query);
while ($row = mysqli_fetch_array($data)) {
if ($row['IP'] == $_SERVER["REMOTE_ADDR"])
{
echo 'Cool';
}
else { echo 'Fail' ; }
?>
</body>
</html>
游戏的目的是证明 IP 地址与数据库中列出的 IP 地址相同。
任何和所有帮助表示赞赏。