in reply to Re: Not able to insert data in mysql
in thread Not able to insert data in mysql
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Not able to insert data in mysql
by erix (Prior) on May 10, 2014 at 06:05 UTC | |
by ashishg0310 (Novice) on May 10, 2014 at 07:56 UTC | |
by ashishg0310 (Novice) on May 10, 2014 at 08:06 UTC | |
|
Re^3: Not able to insert data in mysql
by poj (Abbot) on May 10, 2014 at 07:55 UTC | |
|
Re^3: Not able to insert data in mysql
by thanos1983 (Parson) on May 10, 2014 at 18:04 UTC | |
by Anonymous Monk on May 11, 2014 at 18:59 UTC |