DBD::mysql:st execute failed: Column count doesn't match value count a +t row 1 at dbtest.pl line 22
And here is the SQL statement I used to create the table in question:#!perl -w use strict; use DBI; my $DS="dbi:mysql:QuizTaker"; my $User="tstanley"; my $File="A_Plus_Core.psv"; open(FH,"$File")||die"Can't open $File: $!\n"; my @Array=<FH>; close FH; my $DBH=DBI->connect($DS,$User)||die"Can't connect: $DBI::errstr\n"; my $AnswerE="NULL"; foreach my $element(@Array){ my($TN,$Question,$AnswerA,$AnswerB,$AnswerC,$AnswerD,$Correct)=split + /\|/,$element; chomp($Correct); my $STH=$DBH->prepare_cached(<<SQL); INSERT INTO Questions values(?,?,?,?,?,?,?,?) SQL $STH->execute($TN,$Question,$AnswerA,$AnswerB,$AnswerC,$AnswerD,$Ans +werE,$Correct); } $DBH->disconnect;
Any hints would be greatly appreciated.create table Questions(Test_Number integer(2) NOT NULL, Question varchar(255) NOT NULL, Answer_A varchar(255) NOT NULL, Answer_B varchar(255) NOT NULL, Answer_C varchar(255), Answer_D varchar(255), Answer_E varchar(255), Correct_Answer varchar(10));
In reply to Inserting values into a MySQL database by TStanley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |