This is my first foray into the mystical workings of the DBI module, and I am stuck on a small problem. I am working with MySQL running on Windows 98SE, and I am attempting to load a pipe delimited file into a table. I know that I am successfully connecting to the database itself, but when I execute the statement to insert the data into the table, I get the following error:
DBD::mysql:st execute failed: Column count doesn't match value count a +t row 1 at dbtest.pl line 22

As usual, here's the code:
#!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;
And here is the SQL statement I used to create the table in question:
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));
Any hints would be greatly appreciated.

TStanley
--------
"Suppose you were an idiot... And suppose you were a
member of Congress... But I repeat myself." -- Mark Twain


In reply to Inserting values into a MySQL database by TStanley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.