2013-02-12 110 views
-1
include('config.php'); 
mysqli_select_db($mysqli, "real"); 
if ($transaction == "Success" && $currency == "USD") { 
    $user_ids = '".$user_id."'; $total_cred = `user_credits` +'".$package_credits."'; 
    $add = $mysqli->prepare("UPDATE `users` SET `user_credits` = ? WHERE `user_id` = ?"); 
    $add->bind_param('si', $total_cred,$user_ids); $add->execute(); 
} 

該代碼不會拋出任何錯誤,也不會更新數據庫。Mysqli更新命令不更新

+0

難道你不認爲你的'$ total'說法有錯誤? – hjpotter92 2013-02-12 09:39:59

+0

總積分=(已存入積分)+購買的新積分。 (''。$ package_credits。'')這是具有最近購買的學分的變量 – Shail 2013-02-12 09:42:32

+0

這些表字段具有哪些數據類型? – hjpotter92 2013-02-12 09:44:06

回答

2

更改,如果塊

// $user_ids = '".$user_id."'; REMOVE THE statement 
// $total_cred = `user_credits` + '".$package_credits."'; REMOVE THIS too 
$add = $mysqli->prepare("UPDATE `users` SET `user_credits` = `user_credits` + ? WHERE `user_id` = ?"); 
$add->bind_param('ii', $package_credits, $user_id); $add->execute(); 

讓MySQL的做最困難的部分。

+0

完美工作...感謝您的幫助 – Shail 2013-02-12 10:01:37

-1

試試這個:

include('config.php'); 
mysqli_select_db($mysqli, "real"); 
if ($transaction == "Success" && $currency == "USD") 
{ 
    $user_ids = '".$user_id."'; 
    $total_cred = user_credits +'".$package_credits."'; 
    $add = $mysqli->prepare("UPDATE users SET user_credits = ? WHERE user_id = ?"); 
    $add->bind_param('si', $total_cred,$user_ids); 
    $add->execute(); 
}