我不断为此功能收到以下错误。
解析错误:语法错误,意外' $ tempsql' (T_VARIABLE)in /home/vps20119/public_html/outlet/admin/internal/dcOrderFunctions.php 在第6行
我不明白。在开始定义/声明$ tempsql之前,我找不到任何语法错误。我在看什么?下面是整个文件的副本。
<?php
//A function to extract the QC from the Order number
function orderGetQC($dropcomOrderID){
//Get the Product ID from the order.
$tempsql = "SELECT * FROM `oc_order_product` WHERE `order_id` = '". $dropcomOrderID ."'";
//runs the query (above) and puts the resulting data into a variable called $orderInfo.
$orderInfo = $conn->query($tempsql);
$temprow = $orderInfo->fetch_assoc();
$productID = $temprow['product_id'];
//Get the QC from the product ID.
$tempsql2 = "SELECT * FROM `multi_quantity_received` WHERE `product_id` = '". $productID ."'";
//runs the query (above) and puts the resulting data into a variable called $productInfo.
$productInfo = $conn->query($tempsql2);
$temprow2 = $productInfo->fetch_assoc();
if( $productInfo->num_rows > 1){
$QC = "multipleQCs";
} else {
$QC = $temprow2['qc'];
}
return $QC;
}
?>
答案 0 :(得分:0)
晚上好ID10T错误,
不久前我也有过类似的问题。问题是,我的FTP(FileZilla)开始以 BINARY MODE 而不是 ASCII MODE 上传我的文件。这会导致上传的文件被压缩。这会导致单行注释后的代码出现问题,例如上面代码中显示的代码。
以这段代码为例:
//Get the Product ID from the order.
$tempsql = "SELECT * FROM `oc_order_product` WHERE `order_id` = '". $dropcomOrderID ."'";
这是两个简单,写得很好的PHP行!但是如果FTP将这些行压缩成一个会发生什么呢?你得到这样的东西:
//Get the Product ID from the order. $tempsql = "SELECT * FROM `oc_order_product` WHERE `order_id` = '". $dropcomOrderID ."'";
注意,现在$ tempsql变量被注释掉,使其无法访问(或意外。)在您的特定情况下,它被第一个注释阻止。如果这确实是您的问题,那么您可以采取两项主要措施来解决问题。见下文。
好吧,这真的是一个解决方法而不是一个真正的修复,但如果这有效,你知道这是你的问题!只需将所有单行注释转换为下面的块注释即可。
<?php
/*A function to extract the QC from the Order number */
function orderGetQC($dropcomOrderID){
/* Get the Product ID from the order. */
$tempsql = "SELECT * FROM `oc_order_product` WHERE `order_id` = '". $dropcomOrderID ."'";
/* runs the query (above) and puts the resulting data into a variable called $orderInfo. */
$orderInfo = $conn->query($tempsql);
$temprow = $orderInfo->fetch_assoc();
$productID = $temprow['product_id'];
/* Get the QC from the product ID. */
$tempsql2 = "SELECT * FROM `multi_quantity_received` WHERE `product_id` = '". $productID ."'";
/* runs the query (above) and puts the resulting data into a variable called $productInfo. */
$productInfo = $conn->query($tempsql2);
$temprow2 = $productInfo->fetch_assoc();
if( $productInfo->num_rows > 1){
$QC = "multipleQCs";
} else {
$QC = $temprow2['qc'];
}
return $QC;
}
?>
1)打开FileZilla。
2)单击工具栏上的“编辑”,然后单击“设置”,打开设置菜单。
3)在“转移”组下,单击名为“文件类型”的选项。
4)选择“ASCII”框。
5)按“确定”并尝试再次传输文件。希望它应该有用!
我希望这很有用!如果没有,请发表评论,我们可以尝试解决其他问题!
此致
蒂莫西