简体   繁体   English

插入值列表与列列表不匹配,语句与DB是否对应?

[英]Insert value list does not match column list, statement and DB are corresponding?

I'm working on this page where other users are added, when I want to insert a new user, this is what comes up: 我正在此页面上添加其他用户,当我想插入新用户时,会出现以下情况:

 Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[21S01]: Insert value list does not match column list: 
1136 Column count doesn't match value count at row 1' in /Applications/XAMPP/xamppfiles/htdocs/app/classes/class.users.php:96 Stack trace: #0 

/Applications/XAMPP/xamppfiles/htdocs/app/classes/class.users.php(96): PDO->prepare('INSERT INTO use...') #1 

/Applications/XAMPP/xamppfiles/htdocs/public/pages/nieuweklant.tpl(4): DeGier\Core\Users::addCus() #2 

/Applications/XAMPP/xamppfiles/htdocs/app/classes/class.template.php(20): include('/Applications/X...') #3 

/Applications/XAMPP/xamppfiles/htdocs/app/classes/class.template.php(48): DeGier\Core\Template::getPage('nieuweklant') #4 

/Applications/XAMPP/xamppfiles/htdocs/index.php(11): DeGier\Core\Template::render('nieuweklant') #5 {main} 

thrown in /Applications/XAMPP/xamppfiles/htdocs/app/classes/class.users.php on line 96

Normally, this pops up when I've missed a comma somewhere in the prepare statement, or if the statement isn't corresponding to my DB table, but this time, I believe that none of that has happened. 通常,当我在prepare语句中的某个地方缺少逗号时,或者如果该语句与我的数据库表不对应时,会弹出此消息,但是这次,我认为这一切都没有发生。

This is the PDO Statement: 这是PDO声明:

    $q = self::$connection->prepare('INSERT INTO users VALUES ("", 

:fname, :lname,

 :company, :telephone, :email, :adress, :zipcode, 

    :country, :note)');


    $q->execute(array(":fname" => $_POST['voornaam'], ":lname" => 

$_POST['achternaam'], ":company" => $_POST['bedrijf'],  ":telephone" => 

$_POST['telefoon'], ":email" => $_POST['email'], ":adress" => 

$_POST['adres'], ":zipcode" => $_POST['postcode'], ":country" => 

$_POST['land'], ":note" => $_POST['aantekening']));

I don't believe there's anything wrong there. 我不相信那里有什么问题。

Here is my DB table: 这是我的数据库表:

表

Again, I believe it all matches up. 再次,我相信这一切都匹配。

So, how is it possible that such a big error comes up for none of the default reasons? 因此,怎么可能会由于默认原因而导致如此大的错误呢?

Thanks. 谢谢。

You could try writing in the columns that you wish to insert to. 您可以尝试在要插入的列中编写。 Since your ID is AUTO INCREMENT, it might go wrong when you try to insert an empty string to that field. 由于您的ID为AUTO INCREMENT,因此当您尝试向该字段插入空字符串时,它可能会出错。

   $q = self::$connection->prepare('INSERT INTO users (firstname, lastname, company, phone, email, adress, zipcode, country, note) VALUES ("", 

:fname, :lname,

 :company, :telephone, :email, :adress, :zipcode, 

    :country, :note)');


    $q->execute(array(":fname" => $_POST['voornaam'], ":lname" => 

$_POST['achternaam'], ":company" => $_POST['bedrijf'],  ":telephone" => 

$_POST['telefoon'], ":email" => $_POST['email'], ":adress" => 

$_POST['adres'], ":zipcode" => $_POST['postcode'], ":country" => 

$_POST['land'], ":note" => $_POST['aantekening']));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PDO未捕获的异常-插入值列表与列列表不匹配 - PDO Uncaught exception - Insert value list does not match column list 插入值列表与列列表不匹配:1136 列计数与值计数不匹配 - Insert value list does not match column list: 1136 Column count doesn't match value count MySql语句错误:SQLSTATE [21S01]:插入值列表与列列表不匹配:1136列计数与第1行的值计数不匹配 - MySql statement Error: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1 错误:插入值列表与列列表不匹配:1136列计数与第1行的值计数不匹配 - Error: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1 插入值列表与列列表不匹配:1136 列计数与第 1 行的值计数不匹配 - 但数字相同 - Insert value list does not match column list: 1136 Column count doesn't match value count at row 1 - But the numbers are the same 将行从一个表移动到另一个表(插入值列表与列列表不匹配) - Moving a row from one table to another (Insert value list does not match column list) PDO错误:致命错误:插入值列表与列列表不匹配 - PDO error: Fatal error: Insert value list does not match column list Laravel多个插入无法正常工作时显示“插入值列表不匹配” - Laravel Multiple insert not working says “insert value list does not match ” Laravel 5.4:模型更新失败会产生错误(SQLSTATE [21S01]:插入值列表与列不匹配…) - Laravel 5.4: Model Update Failure produces error (SQLSTATE[21S01]: Insert value list does not match column…) 将具有不同值的多个复选框插入相应的数据库列 - Insert multiple checkbox with different value into corresponding database column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM