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

该代码不会抛出任何错误,也不会更新数据库。

4

2 回答 2

2

将 if 块更改为

//    $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 做最难的部分。

于 2013-02-12T09:45:58.950 回答
-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();
} 
于 2013-02-12T09:58:47.793 回答