2017-06-21 53 views
-2

你能幫助我,請我whant更新我的表X點添加到值:更新PHP的MySQL VAL + 5

$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

去研究該錯誤消息中的等價和綁定聲明和簽證。閱讀PDO如何使用參數查詢實際工作。 – CBroe

回答

0

你有準備的語句混合concatination:

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

每個命名佔位符必須通過

+0

我不明白這一點: Points = Point =:Fr_Points – Jaber

+0

@Jaber對不起我的錯。已更改 – Jens

+0

非常感謝您的幫助! – Jaber