Whenever a query finishes executing, I know you should free the result. Here is a snippet of a class I built for running a simple query. Could someone tell me where I went wrong? The query, when entered properly, runs successfully. It's just that my page doesn't reload like it, should but it gives me these errors...
Fatal error: Call to a member function free() on a non-object in <file> on <line>
... and this error ...
Fatal error: Call to a member function close() on a non-object in <file> on <line>
Here a simplified version of my code:
public function query($query) {
try {
if ($result = $this->connection->query($query, MYSQLI_USE_RESULT)) {
$result->free(); //Problems here
$result->close(); //Problems here
return $result;
} else {
$result->free(); //Problems here
$result->close(); //Problems here
throw new Exception("The query was invalid");
}
} catch (Exception $e) {
die($e->getMessage());
}
}