I have the following code
if(isset($_POST['submit'])){
$activityID = mysqli_real_escape_string($_POST['activityID']);
$date_of_activity = mysqli_real_escape_string($_POST['date']);
$number_of_tickets = mysqli_real_escape_string($_POST['number_of_tickets']);
$db_id = mysqli_real_escape_string($_POST['customerID']);
$sql2 = "INSERT INTO booked_activities(activityID, customerID, date_of_activity, number_of_tickets)
VALUES (?, ?, ?, ?);";
$stmt = mysqli_stmt_init($connection);
if(!mysqli_stmt_prepare($stmt, $sql2)){
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "iiii", $activityID, $db_id, $date_of_activity, $number_of_tickets);
mysqli_stmt_execute($stmt);
}
$bookedresult = mysqli_query($connection, $sql2);
if(!$bookedresult){
echo 'Query Failed ' . mysqli_error($connection); //test for primary duplicate;
} else if ($bookedresult) {
echo "booking registered";
}
}
I'd like to know firstly is using real_esc_string necessary in this case? Also when I submit the form, I get no error message from my if statement but additionally the table does not populate.
My only thought is that the format for the input which I have as iiii is incorrect. I've tried as ssss and I'm getting the same result.
I think maybe I need i(date)ii - if so what's the syntax to specify date time in a prepared statement?