in reply to Inserting values into a MySQL database
The problem is this line:
What happened to Answer E? :)my($TN,$Question,$AnswerA,$AnswerB,$AnswerC,$AnswerD,$Correct)=...
What you end up with is trying to insert only 7 variables where DBI is expecting 8.
In the long run though, follow the advice of Chmrr, dws, and Ovid. It will keep you out of trouble.
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR F--F--F--F--F--F--F--F-- (the triplet paradiddle)
P.S. Brownie points to adamsj for spotting this error too.
P.P.S Or i could be completely wrong about Answer E. I now see that you are indeed assigning the variable $AnswerE to "NULL", which is not the same as NULL. Use undef instead, but you really should specify $AnswerE in the split, i think. How about this instead:
As long as you really include Answer E with the rest in the data file, this code allows you to avoid using temp variables - just pass the output of split. Of course, you might want to do some validation, passing the contents without validating them is not a good thing.foreach my $element(@Array){ chomp $element; # define $STH as you did $STH->execute(split/\|/,$element,8); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) 2Re: Inserting values into a MySQL database
by gav^ (Curate) on Jan 14, 2002 at 07:48 UTC | |
by ralphie (Friar) on Jan 14, 2002 at 17:33 UTC |