Help for this page

Select Code to Download


  1. or download this
    ## get a list of the field names
    my $keys = join (', ', @keys);
    ## get number of placeholders required (number of field names)
    ...
    my $dbh = DBI->connect("DBI:mysql:database=$database;host=localhost", 
    +$username, $password, {'RaiseError' => 1});
    my $sth = $dbh->prepare("INSERT INTO $table ($keys) VALUES ($placehold
    +ers)") or die $dbh->errstr;
    $sth->execute($data) or die $dbh->errstr;