我收到错误消息/警告我语法错误:意外的';'我无法发现出了什么问题
错误行:
$sql .= "'" . db_escape($db, date('Y/m/d') . "'";
我将语法与上面的几行进行比较($ sql。=“'”。db_escape($ db,$ qty)。“'”;),其中语法相似但没有错误消息。因为这是我第一次使用date函数,所以我不确定我的date语法是否错误或是否真的缺少“;”下一行是哪个代码?
if(!isset($SESSION['orderid'])){
$sql = "INSERT INTO orderline ";
$sql .= "(ProductID, OrderQuantity) ";
$sql .= "VALUES (";
$sql .= "'" . db_escape($db, $productID) . "',";
$sql .= "'" . db_escape($db, $qty) . "'";
$sql .= ")";
$result = mysqli_query($db, $sql) or die ("Couldn't execute query.");
if($result){
$_SESSION['message'] = $qty.'item(s) have been added to the cart.';
//maybe redirect page? redirect_to
$_SESSION['orderid'] = mysqli_insert_id($db); //to set the orderID in db to auto increment
}else{
echo mysqli_error($db);
db_disconnect($db);
exit;
}
$sql = "INSERT INTO orders ";
$sql .= "(OrderID, CustomerID, OrderDate) ";
$sql .= "VALUES (";
$sql .= "'" . db_escape($db, $_SESSION['orderid']) . "',";
$sql .= "'" . db_escape($db, $_SESSION['custid']) . "',";
$sql .= "'" . db_escape($db, date('Y/m/d') . "'";//date format consistent with database Y/m/d
$sql .= ")";
$result = mysqli_query($db, $sql) or die ("Couldn't execute query.");
if($result){
$_SESSION['orders'] = 'True';
}else{
echo mysqli_error($db);
db_disconnect($db);
exit;
}
}
没有错误消息或警告