On Monday June 9 2003 3:49 pm, Nazary, David wrote: > Hi, > > I am unable to insert data into MySql with following script: > > #!/usr/bin/perl > use DBI; > use Mysql; > $infile = "/cadfs8/sys/dnazary/mysql_test_data1"; > $dbh = DBI ->connect('DBI:mysql:dnazary_test:localhost', 'root', 'mysql'); > open (IFH, $infile) or die ("Could not open input file."); > foreach (<IFH>) { > (@fields) = split / /, $_; > $query = $dbh->prepare ("INSERT into infiles (keynum,name,model) > VALUES('null','$fields[0]','$fields[1]')"); $query->execute(); > } > close IFH; > $dbh->disconnect();
> > The error I get is: > DBD::mysql::st execute failed: Unknown column 'name' in 'field list' at > ./mysql_write1.pl line 21, <IFH> line 1. > > > However when I remove my column names in the INSERT command as below, it > works. > > $query = $dbh->prepare("INSERT INTO infiles > VALUES('null','$fields[0]','$fields[1]')"); > > I have tried numerous variations of the code and all have failed. Yet every > post on the web claims that it works. Any comments, suggestions would be > much appreciated. > > Thanks > David try using the "do" method instead $query = $dbh->do("INSERT INTO infiles VALUES('null','$fields[0]','$fields[1]')") Greg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]