Thanks a lot for your suggestion of backticks and putting table name in variable. Definitely i am going to use it for my further programs.. As per your suggestion i modified my program but still data is not getting inserted..and execution of program is successful.

#!/usr/bin/perl use strict; use warnings; use DBI; use XML::XPath; use XML::XPath::XMLParser; my $username = "user"; my $password = "userabca"; my $dsn = "dbi:mysql:books:127.0.0.1"; my $dbh = DBI->connect($dsn,$username,$password,{RaiseError => 1,PrintError => 0}) or die "cannot connect to database : $DBI::errstr"; my $xp = XML::XPath->new(filename=>'test.xml'); my $sth = $dbh->prepare(qq{INSERT INTO 'tutpoint_tbl'('tut_id','tut_title','tut_author') VALUES(?,?,?)}); foreach my $row($xp->findnodes('/main/MAIN')){ print "node matched"; my $tut_id = $row->find('tut_id')->int; my $tut_title=$row->find('tut_title')->string_value; my $tut_author=$row->find('tut_author')->string_value; $sth->execute("$tut_id","$tut_title","$tut_author") || die $DB +I::errstr; } $dbh->disconnect;

In reply to Re^2: Not able to insert data in mysql by ashishg0310
in thread Not able to insert data in mysql by ashishg0310

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.