Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert value list does not match column list: 1136 Column count doesn't match value count

Tags:

php

mysql

pdo

I have this PHP-MySQL insert code:

$sqlTeeth = "INSERT INTO teeth (id_logged, patient_id, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eightteen, nineteen, twenty, twone, twtwo, twthree, twfour, twfive, twsix, twseven, tweight, twnine, thirty, thone, thtwo, date_now) VALUES (:id_logged, :patient_id, :one, :two, :three, :four, :five, :six, :seven, :eight, :nine, :ten, :eleven, :twelve, :thirteen,
            :fourteen, :fifteen, :sixteen, :lone, :ltwo, :lthree, :lfour, :lfive, :lsix, :lseven, :leight, :lnine, :lten, :leleven, :ltwelve, :lthirteen,
            :lfourteen, :lfifteen, :lsixteen)";
        $sqlTeethStmt = $conn->prepare($sqlTeeth);
        $sqlTeethStmt->bindValue(":id_logged", $id_logged);
        $sqlTeethStmt->bindValue(":patient_id", $patient_id);
        $sqlTeethStmt->bindValue(":one", $one);
        $sqlTeethStmt->bindValue(":two", $two);
        $sqlTeethStmt->bindValue(":three", $three);
        $sqlTeethStmt->bindValue(":four", $four);
        $sqlTeethStmt->bindValue(":five", $five);
        $sqlTeethStmt->bindValue(":six", $six);
        $sqlTeethStmt->bindValue(":seven", $seven);
        $sqlTeethStmt->bindValue(":eight", $eight);
        $sqlTeethStmt->bindValue(":nine", $nine);
        $sqlTeethStmt->bindValue(":ten", $ten);
        $sqlTeethStmt->bindValue(":eleven", $eleven);
        $sqlTeethStmt->bindValue(":twelve", $twelve);
        $sqlTeethStmt->bindValue(":thirteen", $thirteen);
        $sqlTeethStmt->bindValue(":fourteen", $fourteen);
        $sqlTeethStmt->bindValue(":fifteen", $fifteen);
        $sqlTeethStmt->bindValue(":sixteen", $sixteen);

        $sqlTeethStmt->bindValue(":lone", $lone);
        $sqlTeethStmt->bindValue(":ltwo", $ltwo);
        $sqlTeethStmt->bindValue(":lthree", $lthree);
        $sqlTeethStmt->bindValue(":lfour", $lfour);
        $sqlTeethStmt->bindValue(":lfive", $lfive);
        $sqlTeethStmt->bindValue(":lsix", $lsix);
        $sqlTeethStmt->bindValue(":lseven", $lseven);
        $sqlTeethStmt->bindValue(":leight", $leight);
        $sqlTeethStmt->bindValue(":lnine", $lnine);
        $sqlTeethStmt->bindValue(":lten", $lten);
        $sqlTeethStmt->bindValue(":leleven", $leleven);
        $sqlTeethStmt->bindValue(":ltwelve", $ltwelve);
        $sqlTeethStmt->bindValue(":lthirteen", $lthirteen);
        $sqlTeethStmt->bindValue(":lfourteen", $lfourteen);
        $sqlTeethStmt->bindValue(":lfifteen", $lfifteen);
        $sqlTeethStmt->bindValue(":lsixteen", $lsixteen);

        $sqlTeethStmt->execute();

When I add something to database, I got this error:

SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1

Any Help is appreciated.

like image 766
androidnation Avatar asked Mar 31 '16 07:03

androidnation


1 Answers

Your database table has 35 columns

id_logged, patient_id, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eightteen, nineteen, twenty, twone, twtwo, twthree, twfour, twfive, twsix, twseven, tweight, twnine, thirty, thone, thtwo, date_now

Where as the values you are passing are 34 columns

VALUES (:id_logged, :patient_id, :one, :two, :three, :four, :five, :six, :seven, :eight, :nine, :ten, :eleven, :twelve, :thirteen,
        :fourteen, :fifteen, :sixteen, :lone, :ltwo, :lthree, :lfour, :lfive, :lsix, :lseven, :leight, :lnine, :lten, :leleven, :ltwelve, :lthirteen, :lfourteen, :lfifteen, :lsixteen)

This mismatch of columns is giving you the error.

You forgot to pass the value for date_now column. once you pass it error will be resolved

like image 94
D.k Avatar answered Sep 30 '22 16:09

D.k