<?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, 所以这不是问题..
答案 0 :(得分: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 ";
答案 1 :(得分: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);
答案 2 :(得分: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,
到
$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";
答案 3 :(得分:0)
只需更换50号线
OrderNo = $OrderID";
通过此代码