更新php mysql val + 5

时间:2017-06-21 13:10:28

标签: php mysql sql

你可以帮助我吗,我想更新我的表格,将x点添加到值:

$Fr_Points = 5;
$Fr_Descri = "Un avis a été donné";
$EN_PDO = $pdo->prepare("UPDATE ".$TB_USER_REPORT_STATS." SET Points = Points+".$Fr_Points.", Description=:Fr_Descri WHERE Pseudo='".$Fr_Pseudo."' ");
$EN_PDO->bindParam(":Fr_Points",        $Fr_Points);
$EN_PDO->bindParam(":Fr_Descri",        $Fr_Descri);
$EN_PDO->execute();

但是我收到了一个错误:

Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /xxx/xxx/www/login/avis.php:61 Stack trace: #0 /xxx/xxx/www/login/avis.php(61): PDOStatement->execute() #1 {main} thrown in /xxx/xxx/www/login/avis.php on line 61
你能帮帮我吗? Cordialy

1 个答案:

答案 0 :(得分:0)

你将连接与准备好的陈述混合在一起:

$EN_PDO = $pdo->prepare("UPDATE ".$TB_USER_REPORT_STATS." SET Points = Points+:Fr_Points, Description=:Fr_Descri WHERE Pseudo=:Fr_Pseudo ");

$EN_PDO->bindParam(":Fr_Points",        $Fr_Points);
$EN_PDO->bindParam(":Fr_Descri",        $Fr_Descri);
$EN_PDO->bindParam(":Fr_Pseudo",        $Fr_Pseudo);
$EN_PDO->execute();

每个命名的占位符必须具有等效的in和绑定声明和签证