I'm new to the INSERT ... ON DUPLICATE KEY UPDATE concept and now have been staring at this for an hour and not seeing the problem. Here's the code:
my $stmt = 'INSERT INTO contact_form (' . join(',', keys %sql) . ') VA
+LUES (' . join(',', ('?') x keys %sql) . ') ON DUPLICATE KEY UPDATE '
+. join(' = ?, ', keys %sql) . ' = ?';
Data::Dumper gives me:
$VAR1 = 'INSERT INTO contact_form (more_info,city,name,address,comment
+s) VALUES (?,?,?,?,?) ON DUPLICATE KEY UPDATE more_info = ?, city = ?
+, name = ?, address = ?, comments = ?';
Run-time error message
...for the right syntax to use near ' city = , name = , address = , co
What am I missing? (BTW, it works fine if I leave off the
ON DUPLICATE KEY UPDATE '
+. join(' = ?, ', keys %sql) . ' = ?'
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||