mysqi

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

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"...