TStanley has asked for the wisdom of the Perl Monks concerning the following question:
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));
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inserting values into a MySQL database
by Chmrr (Vicar) on Jan 14, 2002 at 06:03 UTC | |
by dws (Chancellor) on Jan 14, 2002 at 06:15 UTC | |
by gav^ (Curate) on Jan 14, 2002 at 06:39 UTC | |
|
(Ovid) Re: Inserting values into a MySQL database
by Ovid (Cardinal) on Jan 14, 2002 at 06:19 UTC | |
|
(jeffa) 2Re: Inserting values into a MySQL database
by jeffa (Bishop) on Jan 14, 2002 at 06:54 UTC | |
by gav^ (Curate) on Jan 14, 2002 at 07:48 UTC | |
by ralphie (Friar) on Jan 14, 2002 at 17:33 UTC | |
|
Re: Inserting values into a MySQL database
by TStanley (Canon) on Jan 14, 2002 at 07:13 UTC |