$ip = $_SERVER['REMOTE_ADDR'];
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "images";
$id = $_SESSION['id'];
$ti = null;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$sql = "SELECT * FROM `denied` WHERE ip-adress ='".$ip."'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "Sorry " . $row['Name'] . " you have been banned from this site";
}
else {
echo "<form action='' method='POST'> Enter name to continue: <br/> <input type='text' name='name' placeholder='Enter Name'> <input type='submit' name='continue' value='Continue'> </form> ";
}
For Some reason it returns the error:
Notice: Trying to get property of non-object in C:\xampp\htdocs\Projects\test\test.php on line 218
The line in question is this one:
$result = $conn->query($sql);
but I am positive it has something to do with the line:
$sql = "SELECT * FROM `denied` WHERE ip-adress ='".$ip."'";'
>to get the correct syntax highlighting.'".$ip."'. I think you should use a parametrized query. Take a look here, as it sould not be that hard to figure out. php.net/manual/en/mysqli.prepare.php