dtpwra8456 2013-03-12 18:20
浏览 42

使用我的会话时MYSQL查询错误

I am getting the error

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

When performing a query to create a transaction for my shopping cart.

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();
}
}

I am getting confused with my sessions, when I do a var_dump I get this

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" 
}
  • 写回答

1条回答 默认 最新

  • ds15812330851 2013-03-12 18:25
    关注

    you missed FROM clause in your sql

    it should

         SELECT `order_id` FROM  your_table ORDER BY `order_id` DESC LIMIT 1
    
    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)