I'm making a cart database and I want to transfer carts that have been "alive" for 48 hours into an inactive_carts table.
now I have this code, but the problem is, it doesnt put it in the database, i checked and all of the $time
items go in the if command
here's my code:
foreach ($times as $time) {
$username = $time['username'];
$user_id = $time['user_id'];
$cart_id = $time['cart_id'];
$cart_value = $time['cart_value'];
if ($timeAlive >= 12000) {
try {
$queryInctive = $con->prepare('
INSERT INTO inactive_carts(`cart_id` , `username` , `user_id` , `cart_value` , `date`)
VALUES(:cart_id , ":username" , :user_id , ":cart_value" , CURRENT_TIMESTAMP)');
$queryInctive->bindParam(":cart_id" , $cart_id , PDO::PARAM_INT);
$queryInctive->bindParam(":username" , $username);
$queryInctive->bindParam(":user_id" , $user_id , PDO::PARAM_INT);
$queryInctive->bindParam(":cart_value" ,$cart_value );
$queryInctive->execute();
} catch (Exception $e) {
echo "Error is: " . $e->getMessage();
}
}
}
I don't get errors at all. it seems to be all well
NOTE: cart_id is an int , username is a string , user_id is an int, cart_value is an array