There is a table with columns: id (auto_increment), abc and xyz. Then the user fill in a form (I have checked the input) and if the variable combination does not exist in the table (to avoid duplicate entries), it has to be inserted in the table.
This code should check if the combination abc and xyz are already in the database and then insert it.
<?php
$abc = 13;
$xyz = 54;
if ($stmt = mysqli_prepare($link, "IF NOT EXISTS (SELECT 1 FROM table1 WHERE abc = ? AND xyz = ?) BEGIN INSERT table1 (abc, xyz) VALUES (?, ?) END"))
{
mysqli_stmt_bind_param($stmt, "iiii", $abc, $xyz, $abc, $xyz);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
}
?>
Problem: no records are coming into the database. Why?