我试了好几个小时才把数据插入到我的数据库中,没有成功。
$acc_type = $_POST["acc_type"];
$gender = $_POST["geschlecht"];
$first_name = $_POST["vorname"];
$other_names = $_POST["other_names"];
$last_name = $_POST["nachname"];
$date_of_birth = $_POST["date_of_birth"];
$region = $_POST["country"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$passwort1 = $_POST["password"];
$passwort2 = $_POST["password2"];
$sql = "INSERT INTO user (gender, first_name, other_names, last_name, date_of_birth, country, email, phone, password, user_type, email_confirmation_token) VALUES (:gender, :first_name, :other_names, :last_name, :date_of_birth, :country, :email, :phone, :password, :user_type, :email_confirmation-token)";
$statement = $pdo -> prepare($sql);
$result = $statement -> execute(array('gender' => $gender, 'first_name' => $first_name, 'other_names' => $other_names, 'last_name' => $last_name, 'date_of_birth' => $date_of_birth, 'country' => $region, 'email' => $email, 'phone' => $phone, 'password' => $passwort1, 'user_type' => $acc_type, 'email_confirmation_token' => $email_confirmation_token));
每次运行此代码时都会出现以下错误消息:
Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\xampp\htdocs\engine\php\scripts\register_control.php on line 69
在这种情况下,第69行等于执行方法的行宽 ($result = $statement -> execute(...);
发布于 2018-06-05 17:43:28
$result = $statement -> execute(array(':gender' => $gender, ':first_name' => $first_name, ':other_names' => $other_names, ':last_name' => $last_name, ':date_of_birth' => $date_of_birth, ':country' => $region, ':email' => $email, ':phone' => $phone, ':password' => $passwort1, ':user_type' => $acc_type, ':email_confirmation_token' => $email_confirmation_token));
https://stackoverflow.com/questions/-100004752
复制相似问题