我在将记录插入“shipping_order”表时遇到错误。没有插入任何内容,也没有返回错误。
$randomNumber = $order_id = null;
$randomNumber = mt_rand(100, 1000);
$order_id = $user_id.$randomNumber;
$insert = "INSERT INTO shipping_details (order_id,
user_id) VALUES (
:order_id, :user_id
)";
$shipping_details = $db->query($insert, $param);
if ($shipping_details){
foreach ($_SESSION['cart_items'] as $item => $quantity){
$get_name = "select name FROM items WHERE id = :item_id";
$db->query($get_name, array ('item_id' => $item));
$item_names = $db->fetch();
$shipping_order = "INSERT INTO shipping_order (item, quantity, order_id) VALUES (
:item, :quantity, :order_id
)";
$db->query($shipping_order, array('item' => $item_names['name'], 'quantity' => $quantity, 'order_id' => $order_id));
}
}