vendion has asked for the wisdom of the Perl Monks concerning the following question:
This is kind of an odd question, and I may even be doing something wrong that I am not aware of, but I am trying to use variables in a DBI do query for example:
When I try to run my script I get this error from DBI: DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',)' at line 1 at hal9000.pl line 154, <$csvfile> line 2. Looking at my query I don't see where a rouge comma would be coming from. My reason for trying to do this is because I need to read data from multiple files and insert parts of it into a MySQL database. The order that the data is in differs between files so instead of trying to maintain a DBI do query for each file I would rather have one dynamic DBI query if possible.my $columns = 'name,date'; my $values = 'Ben Marcata,2001-05-04'; my $placeholders = '?,?'; $dbh->do("insert into foo (source, $columns, status) values ($placehol +ders)", {}, 'file', $values, '' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using variables in a DBI do queriy
by wind (Priest) on May 04, 2011 at 18:48 UTC | |
by vendion (Scribe) on May 04, 2011 at 19:47 UTC | |
by wind (Priest) on May 04, 2011 at 20:47 UTC | |
by vendion (Scribe) on May 05, 2011 at 14:26 UTC | |
by wind (Priest) on May 05, 2011 at 17:26 UTC | |
| |
|
Re: Using variables in a DBI do queriy
by Anonymous Monk on May 04, 2011 at 18:01 UTC |