1

Where is my problem? thks i don't understand

Warning: PDOStatement::execute(): SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1 in C:\wamp32\www\patest\includes\functions_mysql.php on line 1803

line 1803

$sql = "INSERT INTO ". PREFIX ."comptes VALUES( :reg, :dep, :cat, :nom_ent, :siret, :civilite, :nom, :prenom, :adresse, :code_postal, :ville, :tel, :email, :password, :dossier_rss, :ip, NOW(), :type, :etat)";
$req = $bdd->prepare($sql);
$req->bindValue('reg', $array['reg'], PDO::PARAM_INT);
$req->bindValue('dep', $dep, PDO::PARAM_INT);
$req->bindValue('cat', $cat, PDO::PARAM_INT);
$req->bindValue('nom_ent', $ent, PDO::PARAM_INT);
$req->bindValue('siret', $sir, PDO::PARAM_INT);
$req->bindValue('civilite', $array['civ'], PDO::PARAM_INT);
$req->bindValue('nom', $array['nom'], PDO::PARAM_INT);
$req->bindValue('prenom', $array['prenom'], PDO::PARAM_INT);
$req->bindValue('adresse', $array['add'], PDO::PARAM_INT);
$req->bindValue('code_postal', $cod , PDO::PARAM_INT);
$req->bindValue('ville', $vil, PDO::PARAM_INT);
$req->bindValue('tel', $tel, PDO::PARAM_INT);
$req->bindValue('email', $array['ema'], PDO::PARAM_INT);
$req->bindValue('password', $pas, PDO::PARAM_INT);
$req->bindValue('dossier_rss', $dossier_rss, PDO::PARAM_INT);
$req->bindValue('ip', $array['ip'], PDO::PARAM_INT);
$req->bindValue('type', $type, PDO::PARAM_INT);
$req->bindValue('etat', $etat, PDO::PARAM_INT);
$req->execute();
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • How many columns are there in the table? You're inserting 19 values, so it has to have 19 columns. – Barmar Apr 09 '18 at 21:14
  • 1
    You should use `INSERT INTO table (...) VALUES (...)` or provide the same amount of values as columns you have (probably NULL for the auto_increment ID). – Syscall Apr 09 '18 at 21:14
  • I strongly recommend that you explicitly list the column names you're inserting into. It's dangerous to rely on getting the order of values the same as in the table definition. – Barmar Apr 09 '18 at 21:15
  • I'll bet you left out a value for the auto-increment ID column. If you don't list the columns, you need to provide a value of `NULL` for this column. – Barmar Apr 09 '18 at 21:16
  • for NULL result: Invalid parameter number: number of bound variables does not match number of tokens in.... – Berndt Christophe Apr 09 '18 at 21:33
  • @BerndtChristophe Could you show us the table schema please? `show create table comptes` by example, or `desc comptes`. – Syscall Apr 09 '18 at 21:54

0 Answers0