Php SQLSTATE[HY093]:参数编号无效:未定义参数。。。
我一直在得到SQLSTATE[HY093]错误,但我似乎找不到它的来源。我试图使用表单的参数将一行插入到数据库表中 我从表单中提取了所有参数,它们都正常工作和显示Php SQLSTATE[HY093]:参数编号无效:未定义参数。。。,php,mysql,forms,insert,Php,Mysql,Forms,Insert,我一直在得到SQLSTATE[HY093]错误,但我似乎找不到它的来源。我试图使用表单的参数将一行插入到数据库表中 我从表单中提取了所有参数,它们都正常工作和显示 $q = "INSERT INTO members (mid, firstname, lastname, username, password, email, phone, street, location, gender, ccnumber, expirymonth, expiryyear) VALUES (NULL, :first
$q = "INSERT INTO members (mid, firstname, lastname, username, password, email, phone, street, location, gender, ccnumber, expirymonth, expiryyear) VALUES (NULL, :firstName, :lastName, :username, :password, :email, :phone, :street, :location, :gender, :ccnumber, :expmonth, :expyear);";
$query = $dbConnect->prepare($q);
$enc_password = crypt($password,$username);
//echo 'It is: '.$enc_password.' ';
//echo 'It is: '.$lastName.' ';
$query->bindParam(":firstname",$firstName);
$query->bindParam(":lastname",$lastName);
$query->bindParam(":username",$username);
$query->bindParam(":password",$enc_password);
$query->bindParam(":email",$email);
$query->bindParam(":phone",$phone);
$query->bindParam(":street",$street);
$query->bindParam(":location",$location);
$query->bindParam(":gender",$gender);
$query->bindParam(":ccnumber",$ccnumber);
$query->bindParam(":expirymonth",$expmonth);
$query->bindParam(":expiryyear",$expyear);
//$query->debugDumpParams();
$result = $query->execute();
return $result;
提前感谢:) 您有骆驼箱:
$q = "INSERT ... :firstName, :lastName ...
然后是小写:
$query->bindParam(":firstname",$firstName);
$query->bindParam(":lastname",$lastName);
看起来像是区分大小写的问题
您的查询中还包含:
:expmonth, :expyear
然而,你将它们绑定为:
$query->bindParam(":expirymonth",$expmonth);
$query->bindParam(":expiryyear",$expyear);
$query->bindParam(“:expirymonth”,$expmonth);
$query->bindParam(“:expiryyear”,$expyear)
我想,您在查询中没有定义“expirymonth”和“expiryyear”。
相反,您将其命名为“:expmonth,:expyear”我下面的答案是否有帮助?