-2
<?php
if(isset($_POST['update']))
$dbhost = 'localhost';
$dbuser = 'XXXXX';
$dbpass = 'XXXXX';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}

if(! get_magic_quotes_gpc() )
{
 $OrderID=addslashes ($_POST['OrderID']); 
 $trackingnumber= addslashes ($_POST['trackingnumber']);
 $trackingURL=addslashes ($_POST['trackingURL']); 
 $CustomerName=addslashes ($_POST['CustomerName']); 
 $LocationShipped=addslashes ($_POST['LocationShipped']); 
 $user_email=addslashes ($_POST['user_email']); 
 $ShipmentDate=addslashes ($_POST['ShipmentDate']);
 $ShipmentMode=addslashes ($_POST['ShipmentMode']);  
 $CurrentStatus=addslashes ($_POST['CurrentStatus']);
}
else
{
 $trackingnumber= $_POST['trackingnumber'];
 $trackingURL=$_POST['trackingURL']; 
 $OrderID=$_POST['OrderID']; 
 $CustomerName=$_POST['CustomerName']; 
 $user_email=$_POST['user_email']; 
 $LocationShipped=$_POST['LocationShipped']; 
 $ShipmentDate=$_POST['ShipmentDate'];
 $ShipmentMode=$_POST['ShipmentMode'];  
 $CurrentStatus=$_POST['CurrentStatus'];
}

$sql = "
    UPDATE
        ordertracking
    SET
        trackingnumber =$trackingnumber,
        `trackingURL` = '" . $trackingURL . "',
        `CustomerName` = '" . $CustomerName . "',
        `LocationShipped` = '" . $LocationShipped . "',
        `user_email` = '" . $user_email . "',
        `ShipmentDate` = '" . $ShipmentDate . "',
        `ShipmentMode` = '" . $ShipmentMode . "',
        `CurrentStatus` = '" . $CurrentStatus . "',
    WHERE
        OrderNo = $OrderID,

$result1 = mysql_query($query1);
mysql_select_db('XXXXXXX');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
mysql_close($conn);
?>

解析错误:语法错误,第 46 行 /home/buyerhel/public_html/ordertracking/backend/processeditship.php 中的意外 T_STRING

请问有什么帮助吗?

不确定问题出在哪里,但这真的很令人沮丧,因为我正处于项目编辑部分的最后一步,它允许我更新表格。我故意在这里省略了引号 - trackingnumber =$trackingnumber,所以这不是问题..

4

4 回答 4

2

"您的.文件中没有结束符号$sql。应该:

$sql = "
    UPDATE
        ordertracking
    SET
        trackingnumber =$trackingnumber,
        `trackingURL` = '" . $trackingURL . "',
        `CustomerName` = '" . $CustomerName . "',
        `LocationShipped` = '" . $LocationShipped . "',
        `user_email` = '" . $user_email . "',
        `ShipmentDate` = '" . $ShipmentDate . "',
        `ShipmentMode` = '" . $ShipmentMode . "',
        `CurrentStatus` = '" . $CurrentStatus . "'
    WHERE
        OrderNo = $OrderID"; // < missing ";
于 2013-05-23T12:47:36.570 回答
0

只需更换第 50 行

   OrderNo = $OrderID";

通过这段代码

于 2013-05-23T12:50:18.847 回答
0

您已经使用,而不是;忘记了一些".

$sql = "
    UPDATE
        `ordertracking`
    SET
        `trackingnumber` = " . $trackingnumber . ",
        `trackingURL` = '" . $trackingURL . "',
        `CustomerName` = '" . $CustomerName . "',
        `LocationShipped` = '" . $LocationShipped . "',
        `user_email` = '" . $user_email . "',
        `ShipmentDate` = '" . $ShipmentDate . "',
        `ShipmentMode` = '" . $ShipmentMode . "',
        `CurrentStatus` = '" . $CurrentStatus . "',
    WHERE
        `OrderNo` = " . $OrderID; // ; instead of ,

$result1 = mysql_query($query1);
于 2013-05-23T12:49:45.287 回答
0

两个问题

  1. 关闭双引号
  2. 删除 $OrderID 后面的逗号

所以改变

$sql = "
UPDATE
    ordertracking
SET
    trackingnumber =$trackingnumber,
    `trackingURL` = '" . $trackingURL . "',
    `CustomerName` = '" . $CustomerName . "',
    `LocationShipped` = '" . $LocationShipped . "',
    `user_email` = '" . $user_email . "',
    `ShipmentDate` = '" . $ShipmentDate . "',
    `ShipmentMode` = '" . $ShipmentMode . "',
    `CurrentStatus` = '" . $CurrentStatus . "',
WHERE
    OrderNo = $OrderID,

$sql = "
UPDATE
    ordertracking
SET
    trackingnumber =$trackingnumber,
    `trackingURL` = '" . $trackingURL . "',
    `CustomerName` = '" . $CustomerName . "',
    `LocationShipped` = '" . $LocationShipped . "',
    `user_email` = '" . $user_email . "',
    `ShipmentDate` = '" . $ShipmentDate . "',
    `ShipmentMode` = '" . $ShipmentMode . "',
    `CurrentStatus` = '" . $CurrentStatus . "',
WHERE
    OrderNo = $OrderID";
于 2013-05-23T12:49:53.433 回答