I'm getting the error "SQLSTATE[HY093]: Invalid parameter number" when I try to run this query:
<?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?
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. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.