hi im quite new to this php stuff, and have come across a problem. i cant add the customer order to the database. ive checked using echo $_post['sname']; where my error message is displayed, and it has stored the name, but it dnt add. thanx in advance
function insert_order($order_details)
{
// extract order_details out as variables
extract($order_details);
$conn = db_connect();
$date = date('Y-m-d');
$query = "insert into orders values
('', ".$_SESSION['$valid_user'].", ".$_SESSION['total_price'].", '$date', 'PARTIAL', '$sname',
'$saddress','$scity','$spost')";
$result = $conn->query($query);
if (!$result)
return false;
$query = "select orderid from orders where
customerid = ".$_SESSION['$valid_user']." and
amount > ".$_SESSION['total_price']."-.001 and
amount < ".$_SESSION['total_price']."+.001 and
date = '$date' and
order_status = 'PARTIAL' and
ship_name = '$sname' and
ship_address = '$saddress' and
ship_city = '$scity' and
ship_post = '$spost'";
$result = $conn->query($query);
if($result->num_rows>0)
{
$order = $result->fetch_object();
$orderid = $order->orderid;
}
else
return false;
// insert each dvd
foreach($_SESSION['cart'] as $dvd_no => $quantity)
{
$detail = get_dvd_details($dvd_no);
$query = "delete from order_items where
orderid = '$orderid' and dvd_no = '$dvd_no'";
$result = $conn->query($query);
$query = "insert into order_items values
('$orderid', '$dvd_no', ".$detail['price'].", $quantity)";
$result = $conn->query($query);
if(!$result)
return false;
}
return $orderid;
}