我正在使用pdo php mysql和我正在使用以下脚本进行更新
$pdo = new PDO('mysql:host=79.170.44.155;dbname=cl36-nedal', 'cl36-nedal', 'wC-X.zfUb');
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$statement = $pdo->prepare("update annonce set id_compte= :id_compte , mod=:date_annonce, type= :type , section= :section ,
vac =:vac , bien =:bien , ville=:ville , prix =:prix,sup_glob=:sup_glob , sup_hab=:sup_hab,nbr_chambre=:nbr_chambre,bains=:bains,
etage_app=:etage_app,annee_const:=annee_const,jardin=:jardin,garage=:garage,terrasse=:terrasse,ascenseur=:ascenseur,gardiannage=:gardiannage,
communication=:communication,securite=:securite,balcon=:balcon,picine=:picine,chem=:chem,clima=:clima,sansvi=:sansvi,park_vis=:park_vis,
ter_imm=:ter_imm,info=:info,photo1=:p,photo2=:p1,photo3=:p2,photo4=:p3 where id_annonce =:annonce");
$statement->bindValue(':annonce',$hid);
$statement->bindValue(':id_compte',$id);
$statement->bindValue(':date_annonce',$date);
$statement->bindValue(':type',$type);
$statement->bindValue(':section',$section);
$statement->bindValue(':vac',$vac);
$statement->bindValue(':bien',$_POST['biens']);
$statement->bindValue(':ville',$_POST['villes']);
$statement->bindValue(':prix',$prix);
$statement->bindValue(':sup_glob',$sg);
$statement->bindValue(':sup_hab',$sh);
$statement->bindValue(':nbr_chambre',$nbc);
$statement->bindValue(':bains',$nbs);
$statement->bindValue(':etage_app',$etage);
$statement->bindValue(':annee_const',$annee);
$statement->bindValue(':jardin',$jardin);
$statement->bindValue(':garage',$garage);
$statement->bindValue(':terrasse',$terrase);
$statement->bindValue(':ascenseur',$ascenseur);
$statement->bindValue(':gardiannage',$gardiennage);
$statement->bindValue(':communication',$communication);
$statement->bindValue(':securite',$ss);
$statement->bindValue(':picine',$piscine);
$statement->bindValue(':balcon',$balcon);
$statement->bindValue(':chem',$cham);
$statement->bindValue(':clima',$clim);
$statement->bindValue(':sansvi',$vav);
$statement->bindValue(':park_vis',$pv);
$statement->bindValue(':ter_imm',$ti);
$statement->bindValue(':info',$info);
$statement->bindValue(':p',$tableau[0]);
$statement->bindValue(':p1',$tableau[1]);
$statement->bindValue(':p2',$tableau[2]);
$statement->bindValue(':p3',$tableau[3]);
$statement->execute();
问题是我得到了这个答案
异常->字符串(100)“ SQLSTATE [HY093]:无效的参数编号:绑定变量的数量与令牌的数量不匹配”
请问是什么问题。
在查询中输入错字:
[...snip...] annee_const:=annee_const [...snip...]
^^---
您已将:
和换位=
。因此没有:annee_const
参数,因此是您的错误。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句