2014-09-20 74 views
0

我有幾行代碼:UPDATE MySQL錯誤

$sql = mysql_query("UPDATE user SET txnid='" . mysql_real_escape_string($data['txn_id']) . "', 
    payment_amount='" . mysql_real_escape_string($data['payment_amount']) . "' , 
    payment_status='" . mysql_real_escape_string($data['payment_status']) . "', 
    itemid='" . mysql_real_escape_string($data['item_number']) . "', 
    createdtime='" . mysql_real_escape_string(date("Y-m-d H:i:s")) . "' WHERE id='" . mysql_real_escape_string($_COOKIE["buy_user"]) . "'"; 

    $result = mysql_query($sql); 

我試圖更新ID 117

我知道我必須使用UPDATE,但我不能這樣做。

幫助我

+2

哪裏是你的更新? – rybo111 2014-09-20 17:52:52

+0

所以你想要'更新''用戶''WHERE \'ID \'= 117'而不是'INSERT INTO \'用戶\'VALUES()'? – Sean 2014-09-20 17:55:46

+2

你可以請張貼錯誤,以及?它是否在日誌? – tandy 2014-09-20 18:00:33

回答

0

奇怪的是,你打電話mysql_query功能的兩倍。

我建議你遵循這個模式:

# set a variable to contain just a string, the SQL text you want to execute 
$sql = "UPDATE ... "; 

# the SQL text is conveniently available for debugging/logging 
echo $sql; 

# execute the SQL 
$result = mysql_query($sql);