When I want to write duplicate entry to a UNIQUE column in mysql I get the error Duplicate entry '' for key 'UNIQUE' . Is it possible to use this error as a condition for if() statement in PHP? I use code below to insert entry in column.
$s = "INSERT INTO `table`(`entry`)
if ($conn->query($s) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $s . "<br>" . $conn->error;
}
Aucun commentaire:
Enregistrer un commentaire