Can't insert multiple rows from an array using perl & mysql

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Can't insert multiple rows from an array using perl & mysql

Postby typomaniac » 01. September 2015 23:08

I've been trying to insert various facets of an array using perl into a mysql table to no avail. My initial approach was to do something basic such as


Code: Select all
my $table="table";
foreach $a(@array){
my $state="INSERT INTO ".$table." (uid,item) VALUES (LAST_INSERT_ID(),?)";
my $sth=$dbh->prepare($state);
$sth->execute($a);
}



The array is taken from a series of checkboxes with values numbered from 1 through 7. The best I can get is the first number inserted but then it seems to leave the loop. My hope was to insert into more than one row depending on which check boxes were selected such as:


Code: Select all
uid    item
1         2
1         4

with item being the checkbox selected. I hope I have been detailed enough. I'm using version 1.7.7 with Windows 7 Any help would really be appreciated.
typomaniac
Image
typomaniac
 
Posts: 6
Joined: 16. August 2015 01:16
Operating System: Windows 7

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 74 guests