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 '"\r"' at line 1 at C:/Apache2/cgi-bin/dbi.cgi line 13. #### #!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 TERMINATED 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;