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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.