I'm getting this error
PHP Notice: Trying to get property of non-object in post.php on line 8
on the code below
<?php
if (is_numeric($_GET["id"])) {
$mysqli=mysqli_connect("localhost","xxx","xxx","xxx");
$query = $mysqli->query("SELECT n FROM table WHERE o=".$_GET["id"]);
if ($query) {
if ($query->num_rows === 0) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/?p=".$query->fetch_object()->n);
}
}
mysqli_close($mysqli);
}
else {
echo $_GET["id"];
}
?>
Any idea what's happening? I presumed the checks I had in place would ensure only valid data was being passed
Thanks