小编典典

您的SQL语法有误;第1行的'order(cust_id,order_date,order_total,order_state,order_city,order_add,order'附近)

sql

这出现在我的页面上方

<?php
include("dbconnection.php");

if ($_SESSION["loggedin"] != "true") 
header("Location:memberlogin.php");

$cust_id = $_SESSION["cust_id"];

$result = mysql_query("select customer.*, product.*, order_details.* from customer, product,      
order_details where customer.cust_id=$cust_id and product.pro_id=product.pro_id and    
order_details.order_details_id = order_details.order_details_id")or die(mysql_error());;

$row = mysql_fetch_assoc($result);  
?>

在两者之间,我有另一个总代码

这是下面显示的代码

<?php

if (isset($_POST["logoutbtn"]))
{
header("Location:logout.php");

}

if(isset($_POST["submitbtn"]))
{
$order_id=rand(1000,9999);
$order_date=date("Y-m-d"); 
$order_state=$_POST["order_state"];
$order_city=$_POST["order_city"];
$order_add=$_POST["order_add"];
$order_post=$_POST["order_post"];

echo ("insert into `order`
(cust_id, order_date, order_total, order_state, order_city, order_add, 
order_post)
values('$cust_id','$order_date', 
'$order_total', '$order_state', '$order_city','$order_add','$order_post')")or die(mysql_error());
?>
    <script type="text/javascript">
        alert("Order recorded.");
    </script>
<?php
header("Location:orderview3.php");
}

?>

我有一个错误,说您的SQL语法有错误;在第1行的’order(cust_id,order_date,order_total,order_state,order_city,order_add,order’)附近检查与您的MySQL服务器版本相对应的手册以使用正确的语法


阅读 274

收藏
2021-04-15

共1个答案

小编典典

使用此代码

<?php
include("dbconnection.php");

if ($_SESSION["loggedin"] != "true") {
header("Location:memberlogin.php");
}

$cust_id = $_SESSION["cust_id"];

$result = mysql_query("select customer.*, product.*, order_details.* from customer, product,      
order_details where customer.cust_id=$cust_id and product.pro_id=product.pro_id and    
order_details.order_details_id = order_details.order_details_id")or die(mysql_error());

$row = mysql_fetch_assoc($result);  
?>

并使用本指南>>
http://www.w3schools.com/php/php_syntax.asp

2021-04-15