in reply to Inserting Select Array Material to MySql

Assuming uid is AUTO_INCREMENT try

my $sql = "INSERT INTO $table (uid,mid,qty) VALUES (NULL,?,?)"; my $sth = $dbh->prepare($sql); for (keys %medals){ if ( $medals{$_} > 0 ){ $sth->execute ($_ ,$medals{$_}); } }

LAST_INSERT_ID() will work for the first insert of the session because it will be 0, but subsequent inserts will fail as you try to enter another record with the same uid as the previous one.

poj

Replies are listed 'Best First'.
Re^2: Inserting Select Array Material to MySql
by typomaniac (Novice) on Sep 12, 2015 at 04:43 UTC
    Thanx, sorry for the screwball coding--fixed now. The LAST_INSERT_ID(), was actually tracking from one insert statement to the next. Anyway, on the other issue, I will have to re-post that one although I did find that the wrong column name was listed. The main problem I'm having is to get checkboxes to insert into mysql---if there were 5 boxes and 3 were clicked only one of them shows up in the db. As said before I will post at a later time when I get the xampp server software all working again.