mardi 25 juillet 2017

foreach loop to upload multiple records into mysql table using perl

sub completecheckout {
$uid = $cookievalue;
$cardtype = param('radio1');
$cardnum = param('cardnum');
    foreach $product (@productid) {
        $insert = qq~insert transaction (uid, pid, cctype, ccnum) values ('$uid', '$product', '$cardtype', '$cardnum')~;
        $dbh=DBI->connect($connectionInfo,$user,$passwd);
        $sth=$dbh->prepare($insert);
        $sth->execute();
    }

I am using this code to upload data into a table on mysql from the product array which contains the values of a checkbox group from a form. The script runs and the page displays that it has been uploaded, however nothing was uploaded and there are no errors in my log. Is there any issues with using a foreach loop to upload like this?




Aucun commentaire:

Enregistrer un commentaire