我正在尝试使用PHP在MySQL表中递增一个值。该值需要通过作为参数传递的$ howmany增加。我已经运行了mysqli_error,什么也没得到。我仍然怀疑问题可能是在查询中。有什么想法吗?
代码:
function addPoints($username,$howMany)
{
define('DB_SERVER','n');
define('DB_USERNAME','n');
define('DB_PASSWORD','n');
define('DB_NAME','n');
$link = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_NAME);
$currPoints = obtainPoints($username);
$currPoints+=$howMany;
$query = 'UPDATE `users` SET `points` = '.$currPoints.' WHERE `users`.`id=`'.fetchIDByUsername($username);
$result = mysqli_query($link,$query);
}
来自我的评论:
问题是users
。id=
部分。
尝试以下内容:
'UPDATE `users` SET `points` = '.$currPoints.' WHERE `users.id` = '.fetchIDByUsername($username);