gpt4 book ai didi

php - PDO异常 : SQLSTATE[HY093]: Invalid parameter

转载 作者:行者123 更新时间:2023-11-29 10:34:18 24 4
gpt4 key购买 nike

当我想更新数据库时出现错误。

Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\xampp\htdocs\unija\aids\admin\project.php:85 Stack trace: #0 C:\xampp\htdocs\unija\aids\admin\project.php(85): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\unija\aids\admin\project.php on line 85

$stmt = $DB_con->prepare('UPDATE Projekti SET NaslovSrpski=:naslovs, NaslovEngleski=:naslove, Nosilac=:nosilac, Partneri=:part, Teritorija=:ter, Vrednost=:vrednost, Donator=:donator, TrajanjeOD=:trajanjeod, TrajanjeDO=:trajanjedo, TekstSrpski=:teksts, TekstEngleski=:tekste, Slika=:upic WHERE ID=:uid');
$stmt->bindParam(':naslovs',$NaslovSrpski);
$stmt->bindParam(':naslove',$NaslovEngleski);
$stmt->bindParam(':nosilac',$Nosilac);
$stmt->bindParam(':part',$Partneri);
$stmt->bindParam(':ter',$Teritorija);
$stmt->bindParam(':vrednost',$Vrednost);
$stmt->bindParam(':donator',$Donator);
$stmt->bindParam(':trajanjeod',$TrajanjeOD);
$stmt->bindParam(':trajanjedo',$TrajanjeDO);
$stmt->bindParam(':teksts',$TekstSrpski);
$stmt->bindParam(':tekste',$TekstEngleski);
$stmt->bindParam(':upic',$userpic);

if($stmt->execute())
{
$successMSG = "Uspesno ste dodali projekat!";
header("index.php"); // redirects image view page after 5 seconds.
}
else
{
$errMSG = "error while inserting....";
}

完整代码:http://gamers.rs/php.txt

最佳答案

你忘记了一个绑定(bind):

$stmt->bindParam(':uid',$id);

希望有帮助:D

关于php - PDO异常 : SQLSTATE[HY093]: Invalid parameter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46754036/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com