I'm trying to catch error messages returned from a mysql server on insert failure. The below method works fine when fetching data, but on insert, the 'if' statement below inserts the data a second time. How can I re-write this to catch error messages without inserting the data again.
$mysqli = new mysqli("localhost", "user", "pass", "database");
$query_storeReturnedData = "INSERT INTO `eventStore` (table_key, event_type, event_date,) VALUES(NULL, 'Unix Event', '2010-08-24 12:00:00')";
$mysqli->query($query_storeReturnedData);
if(!$mysqli->query($query_storeReturnedData))
{
printf("Errormessage: %s\n", mysqli_error($mysqli));
}