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. 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?
在我运行之后,这个查询将给出一个结果“工作”,但不会更新db。关于这个错误,我尝试搜索相同的问题,但没有帮助我修复。你能帮我看看这个查询有什么问题吗?
Thank you
谢谢你!
2 个解决方案
#1
0
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));
#2
0
$qep
is a statement object, and will always be truthy. You need to capture the result of executing the statement:
$qep是一个语句对象,并且始终是真实的。您需要捕获执行语句的结果:
$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值而不检查它们是否设置,也可能会给您带来很多警告。
#1
0
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));
#2
0
$qep
is a statement object, and will always be truthy. You need to capture the result of executing the statement:
$qep是一个语句对象,并且始终是真实的。您需要捕获执行语句的结果:
$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值而不检查它们是否设置,也可能会给您带来很多警告。