in reply to Re^2: insert perl dumper value in mysql
in thread insert perl dumper value in mysql

Oops, sorry, I misunderstood. I know that you're trying to insert multiple values, but you can't supply array references to that single insert statement and expect that it's going to insert multiple rows. It's possible to do with one statement, but that involves building a statement which has as many question marks as you have values to pass. It'd be easier to simply loop over the values in your @out array and insert them one at a time.

For example, with the insert statment you have, something like:
for my $idx (0..$#{$out->[0]}) { ...prepare your insert statmenet here, inside the loop... $insert->execute($out[0]->[$idx],$out[1]->[$idx],$out[2]->[$idx],$ +out[3]->[$idx]) }
That'll run many insert statements, but should do what you want (I think!). Note that I'm not passing $out[0] itself, for example, but rather each element as indexed by $idx in turn.

Replies are listed 'Best First'.
Re^4: insert perl dumper value in mysql
by sharan (Acolyte) on Mar 19, 2009 at 14:39 UTC
    I tried with ur new solution.. But still its not working.. \n Nothing enters into the table.. and infact when i compile the program it shows error
    Number of rows deleted: 0 Can't use string ("play") as an ARRAY ref while "strict refs" in use a +t ./checkstring.pl line 44. $VAR1 = [ 'read', 'eat', 'play' ];
      Did you undo the changes I asked you to make originally, in the first comment, regarding square brackets? Remember I said that that created an array reference, and this error message is complaining that it wants an array reference.