I am trying to get my PHP to execute this script that inserts data from one table into another but with 2 WHERE conditions, "userID" AND
"confirmation" but it is only working if I set only 1 WHERE condition i.e WHERE confirmation = :confirmation
.
I need to have a AND
so that the script only affects the individual session user (userID) rather than all users.
I tried using a comma instead of AND
but still nothing.
I also tried typing them like userID = '$userID' AND confirmation = :confirmation
but still nothing.
$charizard = $dbh->prepare("INSERT INTO orders (email, first_name, last_name, product, quantity, date, price)
(SELECT email, first_name, last_name, product, quantity, date, price FROM checkout WHERE userID = :userID AND confirmation = :confirmation)");
$charizard->bindParam(':userID', $userID);
$charizard->bindParam(':confirmation', $confirmation);
if ($charizard->execute())
{
$delete_stmt = $dbh->prepare("DELETE FROM checkout WHERE userID = :userID AND confirmation = :confirmation");
$delete_stmt->bindParam(':userID', $userID);
$delete_stmt->bindParam(':confirmation', $confirmation);
$delete_stmt->execute();
}