我是PHP的初学者,目前,我正在开发我的PHP添加客户端用户帐户。我无法添加到数据库中,我收到了此警告。 警告:PDOStatement :: execute():SQLSTATE [HY093]:无效的参数编号:绑定变量的数量与令牌数量不匹配我找不到针对我的问题的特定解决方案。我们将非常感谢您的帮助。这是我的PHP代码。
<?php
include 'config.php';
if ($_POST) {
try {
$clientunum = "";
$username = ($_POST['username']);
$userpass = ($_POST['userpass']);
$user_fname = ($_POST['user_fname']);
$user_lname = ($_POST['user_lname']);
$user_bdate = ($_POST['user_bdate']);
$companyname = ($_POST['companyname']);
$user_mobilenum = ($_POST['user_mobilenum']);
$rbStatus = ($_POST['rbStatus']);
// ******* FOR PHOTO START *********
$file = $_FILES['user_photopath'];
$filetmp = $_FILES["user_photopath"]["tmp_name"];
$filename = $_FILES["user_photopath"]["name"];
$filetype = $_FILES["user_photopath"]["type"];
$userphotopath = "usersimg/".$filename;
move_uploaded_file($filetmp, $userphotopath);
// ***** FOR PHOTO END ******
// ***** QUERY
$query = "INSERT INTO client SET CLIENT_UNUM=?, USERNAME=?, USERPASS=?,
USER_FNAME=?, USER_LNAME=?, USER_BDATE=?, USER_PHOTOPATH=?, COMPANY_NAME,
STATUS=?, USER_MOBILENUM=?";
$stmt = $conn->prepare($query);
$stmt -> bindParam(1,$clientunum);
$stmt -> bindParam(2,$username);
$stmt -> bindParam(3,$userpass);
$stmt -> bindParam(4,$user_fname);
$stmt -> bindParam(5,$user_lname);
$stmt -> bindParam(6,$user_bdate);
$stmt -> bindParam(7,$userphotopath);
$stmt -> bindParam(8,$companyname);
$stmt -> bindParam(9,$rbStatus);
$stmt -> bindParam(10,$user_mobilenum);
$stmt -> execute();
//header("location:addnewuseraccount.php");
// echo "<a href='records.php'>View Records</a>";
}
catch (Exception $e) {
echo "ERROR:".$e->getMessage();
}
}
else{
header("location:index.php");
}
?>
答案 0 :(得分:1)
你错过了COMPANY_NAME =?,
答案 1 :(得分:0)
您忘记了COMPANY_NAME,
$query = "INSERT INTO client SET CLIENT_UNUM=?, USERNAME=?, USERPASS=?,
USER_FNAME=?, USER_LNAME=?, USER_BDATE=?, USER_PHOTOPATH=?, COMPANY_NAME=?,
STATUS=?, USER_MOBILENUM=?";