0
當我收到錯誤MySQL查詢錯誤使用我的會話
Query2 Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , ,)' at line 1
當執行一個查詢創建我的購物車的交易。
function addNewTransaction($mem_id, $mem_tel, $mem_address, $mem_city, $mem_county, $mem_postcode, $mem_country, $item_id, $price, $each_item) {
// Insert into the transactions table
$query1 = mysql_query("INSERT INTO transactions (mem_id, OrderDate, Ship_Phone, Ship_Address, Ship_City, Ship_County, Ship_PostCode, Ship_Country) VALUES($member_data('mem_id'), NOW(), $member_data('mem_tel'), $member_data('mem_address'), $member_data('mem_city'), $member_data('mem_country'), $member_data('mem_postcode'), $member_data('mem_country'))");
if($query1) {
// Get the highest ID in the transactions table. This should be the ID of the row we just inserted.
$tempInfo = mysql_query("SELECT `order_id` ORDER BY `order_id` DESC LIMIT 1");
$tempInfo = mysql_fetch_assoc($tempInfo);
$orderId = $tempInfo['order_id'];
// Insert into the transaction details table.
$query2 = mysql_query("INSERT INTO `transactionDetails` (Order_ID, Product_ID, Price, Quantity) VALUES({$orderId}, {$item_id}, {$price}, {$each_item})");
if($query2) {
// Success.
} else {
// Error occurred.
echo 'Query2 Error: ' . mysql_error();
}
} else {
// Error occurred.
echo 'Query1 Error: ' . mysql_error();
}
}
我越來越困惑與我的會話,當我做了的var_dump我得到這個
array(5) {
["num_user"]=> string(1) "1"
["mem_id"]=> string(2) "11"
["cartTotal"]=> string(53) "Cart Total: £8.99 GBP"
["cart_array"]=> array(1) {
[0]=> array(3) {
["item_id"]=> string(1) "7"
["quantity"]=> int(1)
["price"]=> NULL
}
}
["product_price"]=> string(4) "1.99"
}
[ **請不要在新代碼中使用'mysql_ *'函數**](http://bit.ly/phpmsql)。他們不再被維護[並且被正式棄用](http://j.mp/XqV7Lp)。看到[**紅框**](http://j.mp/Te9zIL)?學習[*準備的語句*](http://j.mp/T9hLWi),並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [這篇文章](http://j.mp/QEx8IB)將幫助你決定哪個。 – Kermit 2013-03-12 18:23:34
var_dump($ query1);和其他人看看哪一個是錯的,問題是什麼。 – mkaatman 2013-03-12 18:23:45
@mkaatman我收到兩個 – jhetheringt7 2013-03-12 18:25:44