【发布时间】:2023-03-06 23:56:01
【问题描述】:
我收到了一条错误消息,其中包含我使用的以下代码。我收到的错误消息是:
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();
}
?>
感谢您的帮助:)
【问题讨论】:
标签: php mysql error-handling shopping-cart