首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >插入数据库时​​出现错误(Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined)

插入数据库时​​出现错误(Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined)
EN

Stack Overflow用户
提问于 2018-06-05 07:45:05
回答 1查看 0关注 0票数 0

我试了好几个小时才把数据插入到我的数据库中,没有成功。

代码语言:javascript
复制
$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));

每次运行此代码时都会出现以下错误消息:

代码语言:javascript
复制
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(...);

EN

回答 1

Stack Overflow用户

发布于 2018-06-05 17:43:28

代码语言:javascript
复制
$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));
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100004752

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档