0
我有一個錯誤消息與我已經使用以下代碼。我得到的錯誤信息是:PHP Shoppinf購物車錯誤消息
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order values (34 1,1,250,2011-11-09,jahed)' at line 1
我在下面提供的代碼從第1行開始!
<?php
session_start();
?>
<?php
if(!isset($_SESSION["username"]))
{
header("Location: shoppinglogin.php");
}
?>
<?
include("includes/db.php");
include("includes/functions.php");
if($_REQUEST['command']=='update'){
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$address=$_REQUEST['address'];
$phone=$_REQUEST['phone'];
$result=mysql_query("insert into customers values('','$name','$email','$address','$phone')");
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
$orderid=mysql_insert_id();
$pid=$_SESSION['cart'][$i]['productid'];
$q=$_SESSION['cart'][$i]['qty'];
$price=get_price($pid);
$date=date('Y-m-d');
$user=$_SESSION['username'];
mysql_query("insert into order values ('$orderid','$pid','$q','$price','$date','$user')")
or die(mysql_error());
}
die('Thank You! your order has been placed!');
session_unset();
}
?>
感謝所有幫助:)
太感謝你了...它的工作原理:d – Jahed