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!!
In reply to Problem loading txt file into mysql by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |