0

エラーが発生しています

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" 
}
4

1 に答える 1

2

FROMあなたのSQLで句を逃した

そうすべき

     SELECT `order_id` FROM  your_table ORDER BY `order_id` DESC LIMIT 1
于 2013-03-12T18:25:49.090 に答える