There are two errors in your code.
First, your SQL statement is not syntactically correct, because you have the word GO at its end:
my $insert= $dbh->prepare("INSERT INTO $table ($columns) VALUES ($rows +)GO");
Second, you are not properly quoting your values. Strings must be passed in (most) SQL databases surrounded by single quotes, while numbers are not allowed to have single quotes.
You should really be using placeholders so you don't need to guess as to what has to be quoted and what not and what the correct quoting characters are:
# Construct a string of "?" as the placeholders: my $placeholders = join ",", map { "?" } keys %{$mirror{"$Itemnumber"} +{"$table"}}; my $insert= $dbh->prepare("INSERT INTO $table ($columns) VALUES ($plac +eholders)"); $insert->execute(values %{$mirror{"$Itemnumber"}{"$table"}});
In reply to Re: Inserting to MySQL 4.1 database using Perl DBI
by Corion
in thread Inserting to MySQL 4.1 database using Perl DBI
by Mr.Churka
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |