i got perl script which was working fine till recently .nothing was changed .This is back office script and the data it gets is from a trusted source.i didnt write it and i know very little about perl

foreach my $xmlfile (@productfiles) { my $XML = XML::Smart->new($xmlfile) or warn("Unable to parse $xmlfil +e: $!"), next; $XML = $XML->cut_root(); next if (!defined $XML->{Product}{Code} || $XML->{Product}{Code}->co +ntent != 1); my $prodid = $XML->{Product}{ID}; my @features = @{$XML->{Product}{ProductFeature}}; foreach my $feature (@features) { my $cat_featureid = $feature->{CategoryFeature_ID}; my $value = $feature->{Presentation_Value}; my $sql = "INSERT INTO products_features (product_id, feature_id, +value) VALUES (".$prodid.", ".$cat_featureid.", ".$dbh->quote($value) +.") ON DUPLICATE KEY UPDATE value=".$dbh->quote($value); $dbh->do($sql); print Dumper $sql; } undef $XML; $c_processed++; print "." if ($c_processed % 10 == 0); # indicate progress as operat +ions can take a long time } print "$c_processed product feature values imported or updated.\n";
I tried to debug the script to see where the erroe happens and this is what i got from dumper.
$VAR1 = 'INSERT INTO products_features (product_id, feature_id, value) VALUES (9589372, 34200, \'Brother HL3040\') ON DUPLICATE KEY UPDATE value=\'Brother HL3040\'';
$VAR1 = 'INSERT INTO products_features (product_id, feature_id, value) VALUES (9589372, 41695, \'1\') ON DUPLICATE KEY UPDATE value=\'1\'';

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 ' '') ON DUPLICATE KEY UPDATE value=''' at line 2 at import_productfeatures.pl line 71.

I would appreciate if anyone can look at it..

In reply to error ..ON DUPLICATE KEY UPDATE value=''' by nafri

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.