Problem with code - unexpected $end ? Tried for a good half an hour now to fix this problem....
Can you spot the problem?
<?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>
The aim of the game is to testify that the IP address is the same as the one listed in the database.
Any & all help appreciated.