如何将PHP变量的值添加到数据库中的值?我被迫使用PDO,所以这是我到目前为止所拥有的,它可以很好地添加20到声誉;
$rep = $conn->prepare("UPDATE `users` SET `reputation` = `reputation` + 20 WHERE `email` = :email");
$rep->bindParam(":email", $_SESSION['email']);
$rep->execute();
现在,我不想在reputation
中添加一个名为$repbonus的变量,所以我尝试了这个:
$rep = $conn->prepare("UPDATE `users` SET `reputation` = `reputation` + :rep WHERE `email` = :email");
$rep->bindParam(":email", $_SESSION['email']);
$rep->bindParam(":rep", $repbonus);
$rep->execute();
它不工作,但是,任何指针?
我的道歉,似乎我犯了一个打字错误,说bindParma而不是bindParam。