php - Insert value list does not match column list, statement and DB are corresponding? -
i'm working on page other users added, when want insert new user, comes up:
fatal error: uncaught exception 'pdoexception' message 'sqlstate[21s01]: insert value list not match column list: 1136 column count doesn't match value count @ 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 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, pops when i've missed comma somewhere in prepare statement, or if statement isn't corresponding db table, time, believe none of has happened.
this pdo statement:
$q = self::$connection->prepare('insert 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 wrong there.
here db table:

again, believe matches up.
so, how possible such big error comes none of default reasons?
thanks.
you try writing in columns wish insert to. since id auto increment, might go wrong when try insert empty string field.
$q = self::$connection->prepare('insert 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']));
Comments
Post a Comment