Hello Monks, I am having a database problem. I am trying to make a standard select statement call using DBI but I am having trouble understanding the DBI module and getting my script to work. I tested my select statement in the mysql database and it worked fine so I know the problem must lie in the perl. Here is my code:
use warnings; use strict; use DBI; my $dbh = DBI->connect("DBI:mysql:database=bing_music_scrape;host=loca +lhost", "root", "", {'RaiseError' => 1}); my $sth = $dbh->prepare("SELECT domain,path FROM Directory WHERE expir +es <= CURDATE()); "); if (!$sth) { die "Error:" . $dbh->errstr . "\n"; } my $results = $sth->fetchall_hashref([ qw(domain path) ]); print "done!\n";
The error occurs while executing this:
my $results = $sth->fetchall_hashref([ qw(domain path) ]);
And this is the error:
DBD::mysql::st fetchall_hashref failed: statement contains no result [ +err was 4 now 2000000000] Field 'domain' does not exist (not one of ) at /home/shrikis/workspace +/load/janitor.pl line 14. at /home/shrikis/workspace/load/janitor.pl line 14.
What am I doing wrong?
In reply to Use DBI to select and return multiple database entries by jayto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |