I have the following prepared statement which works and allows me to enter information into the table as required. However I'm not getting any return for the if-not part of the statement. I'd like the error message to appear on the website if the information is not input into the table for example if I have a duplicate entry it will not work with my table but I just get the else{} part and booking has been registered when in fact the table has not changed.
$stmt = mysqli_stmt_init($connection);
if(!mysqli_stmt_prepare($stmt, $sql2)){
echo "
<div class='registered'>
Cannot book same activity twice
</div>";
} else {
mysqli_stmt_bind_param($stmt, "ssss", $activityID, $db_id, $date_of_activity, $number_of_tickets);
mysqli_stmt_execute($stmt);
echo "<div class='registered'>
<h2>Your booking has now been registered<h2>
</div>
";
}