At the moment I am trying to insert into 4 separate tables using 4 separate INSERT commands.
I only want this to happen if all 4 of the INSERTS are successful. If any of the INSERT's fail then I do not want any of the data to be entered into the DB.
At the moment I have a very ugly looking php IF statement which I'd rather not include here as I'm sure there must be a better way.
You should use transaction:
<?php
$conn = mysqli_connect(...)
mysqli_begin_transaction($conn);
//do some inserts
if($insert1 && $insert2 ..) {
mysqli_commit($conn);
} else {
mysqli_rollback($conn);
}
Depending on your database configs, you should disable autocommit: mysqli_autocommit($conn, false);