[英]PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number:
I'm getting the error "SQLSTATE[HY093]: Invalid parameter number" when I try to run this query: 尝试运行此查询时,出现错误“ SQLSTATE [HY093]:无效的参数号”:
<?php
include "../config/c_config.php";
$db = dbConn::getConnection();
$pmuid = $_POST['txtuid'];
$pnml = $_POST['txtnm'];
$ptgll = $_POST['txttgl'];
$jk = $_POST['optjk'];
$palamat = $_POST['txtalamat'];
$idv = $_POST['cbprov'];
$idc = $_POST['cbcity'];
$pkode = $_POST['txtkodepos'];
$pphone= $_POST['txtnophone'];
$pemkof= $_POST['txtmailinf'];
$pimg = $_POST['fileimg'];
$pdate=date("Y-m-d H:i:s");
// Update data on mysql
$sqlep = "UPDATE str_user_mamber_profile SET
profile_nama_lengkap=:pnml,
profile_jk=:jk,
profile_tgl_lahir=:ptgll,
profile_alamat=:palamat,
id_provinsi=:idv,
id_city=:idc,
profile_kodepos=:pkode,
profile_phone=:pphone,
profile_email_konfirmasi=:pemkof,
profile_date=:pdate
WHERE mamber_unique_id = :pmuid";
$qep = $db->prepare($sqlep);
$qep->execute(array(":pnml"=>$pnml,
":jk"=>$jk,
":ptgll"=>$ptgll,
":palamat"=>$palamat,
":idv"=>$idv,
":idc"=>$idc,
":pkode"=>$pkode,
":pphone"=>$pphone,
":pemkof"=>$pemkof,
":pdate"=>$pdate,
":pmuid"=>$pmuid));
if($qep){
echo 'work';
}else{
echo 'not work';
}
?>
after i run,this query give a result "WORK" but not update the db. 运行后,此查询给出结果“ WORK”,但不更新数据库。 i try search same question about this error but not help me to fixed.
我尝试搜索有关此错误的相同问题,但无法帮助我解决。 can you help me see what is wrong with the query?
您能帮我看看查询出了什么问题吗?
Thank you 谢谢
change 更改
":pnml"=>$pnml,
to 至
"pnml"=>$pnml,
everywhere in "execute" method 处处采用“执行”方法
$qep->execute(array("pnml"=>$pnml,
"jk"=>$jk,
"ptgll"=>$ptgll,
"palamat"=>$palamat,
"idv"=>$idv,
"idc"=>$idc,
"pkode"=>$pkode,
"pphone"=>$pphone,
"pemkof"=>$pemkof,
"pdate"=>$pdate,
"pmuid"=>$pmuid));
$qep
is a statement object, and will always be truthy. $qep
是一个语句对象,并且永远是真实的。 You need to capture the result of executing the statement: 您需要捕获执行语句的结果 :
$result = $qep->execute(...);
if ($result){
echo 'work';
} else {
echo 'not work';
var_dump($qep->errorInfo());
}
Using $_POST
values without checking that they are set may give you lots of warnings, as well. 使用
$_POST
值而不检查是否已设置它们也会给您很多警告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.