An INSERT statement, which I am using to post data derived from an HTML form into the MySQL database, does not properly execute. The execute statement returns false. However, no error message is issued. I really don't know where the problem lies. Here's the code:
Input data from form:
$order_id = $_POST['order_id'];
$container_id = $_POST['container_id'];
$quantity = $_POST['quantity'];
$confirmation_date = $_POST['confirmation_date'];
SQL statements:
$query = "INSERT INTO confirmation (order_id, container_id, quantity, confirmation_date) VALUES (?, ?, ?, ?)";
if (!($stmt = mysqli_prepare($dbc, $query))) echo "Error 1";
if (!(mysqli_stmt_bind_param($stmt, "iiis", $order_id, $container_id, $quantity, $confirmation_date))) echo "Error 2";
if(!(mysqli_stmt_execute($stmt))) echo "Error 3";
$affected_rows = mysqli_stmt_affected_rows($stmt);
mysqli_stmt_close($stmt);
if(!$affected_rows == 1) {
echo mysqli_error($dbc);
mysqli_close($dbc);
}
The affected rows are always 0 and no entry to the database is made.
The MySQL table is named "confirmation". It has 5 columns:
confirmation_id (primary, auto increment),
order_id (int(5)),
container_id (int(7)),
quantity (int(10)),
confirmation_date (date)
The connection to the database works, as I already use it in other scripts.