I have a SQL string that updates my DB
I have left out most of the insert code as this is not where I need help. I run the string updating numerous tables but I need to stop the string once an error is detected.
I have in the first SQL string a Unique coulomb that i do not want duplicates of but in the other tables duplicates of the same coulomb doesn't matter. As this is history tables keeping history of the objects
This section is the sql section thereafter I start the sql 1
if ($conn->query($sql) === TRUE) {
echo "Client and Unit has been loaded ";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
echo("Error description: " . mysqli_error($con));
echo "Error in uploading information";
}
$sql1 = "INSERT INTO unit_history SET
The error is correct and the table is not populated but it goes on to the next sql1 string I need it to stop once the error is found.
Duplicate entry '111' for key 'unitnr' Notice: Undefined variable: con in client_rep.php on line 120
Is there a way I can Kill the script once error is noted on duplicate entry?