Mysqli更新命令不更新
问题描述:
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更新命令不更新
答
更改,如果块
// $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
答
试试这个:
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();
}
难道你不认为你的'$ total'说法有错误? – hjpotter92 2013-02-12 09:39:59
总积分=(已存入积分)+购买的新积分。 (''。$ package_credits。'')这是具有最近购买的学分的变量 – Shail 2013-02-12 09:42:32
这些表字段具有哪些数据类型? – hjpotter92 2013-02-12 09:44:06