Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I have a problem to uploading a text file into mysql.
The following errors is showing:
You have an error in your SQL syntax. Check the manual that correspon +ds to your MySQL server version for the right syntax to use near '"\r +"' at line 1 at C:/Apache2/cgi-bin/dbi.cgi line 13.
Here is my coding for your view
#!d:\perl\bin\perl use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; print header; print start_html("Results"); my $dbh=DBI->connect('DBI:mysql:test','root','') or die "Can't connect + $DBI::errstr"; my $sql=qw(load data local infile 'temp.txt' into table t1 FIELDS TERM +INATED BY ',' OPTIONALLY ENCLOSED BY """",LINES TERMINATED BY "\r"); #my $sql ="insert into t1 values('kushboo', 1)"; ## ITS WORKING my $sth=$dbh->prepare($sql) || die "$DBI::errstr"; $sth->execute || die "$DBI::errstr"; $dbh->disconnect; print end_html;
Thanks in Advance!!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Problem loading txt file into mysql
by rnahi (Curate) on Dec 29, 2005 at 12:19 UTC | |
Re: Problem loading txt file into mysql
by spadacciniweb (Curate) on Dec 29, 2005 at 09:39 UTC | |
Re: Problem loading txt file into mysql
by Michalis (Pilgrim) on Dec 29, 2005 at 09:50 UTC | |
Re: Problem loading txt file into mysql
by kulls (Hermit) on Dec 29, 2005 at 09:54 UTC |
Back to
Seekers of Perl Wisdom