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.
bindValue(':foo:, $value);
if it's field number coincides with yourSQL fields
– Nobell$record->save()
instead of this gigantic sprawling amount of code you have here. – Shelf