How to avoid inserting data twice in MySQL using PHP and mysqli

Service

New Member
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. \[code\] $mysqli = new mysqli("localhost", "user", "pass", "database"); $query_storeReturnedData = "http://stackoverflow.com/questions/3553472/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)); }\[/code\]
 
Back
Top