Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to insert data into mysql database using perl without succes.
i get the following error :
Name "main::DATA" used only once: possible typo at write.pl line 10. readline() on unopened filehandle DATA at write.pl line 10.
please,what am I doing wrong?my script:
#!/usr/bin/perl use strict; use warnings; use DBI; my $dbh=DBI->connect('DBI:mysql:database=test;host= localhost','root','mypassword',{RaiseError =>1,AutoCommit=>1},); + my $sql='INSERT INTO foo(Item1,Item2)VALUES(wahed,jouj)'; my $sth=$dbh->prepare($sql); while(<DATA>){ chomp; my @vals=split /\s+/, $_; $sth->execute(@vals); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl and mysql
by moritz (Cardinal) on Apr 22, 2010 at 10:17 UTC | |
by Anonymous Monk on Apr 22, 2010 at 17:15 UTC |