Hi Monks, I am having some trouble with a MySQL statement, or rather the fetchrow_hashref to get the data. It always returns the error message "DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at", but nevertheless the results are completely fine and as expected. I have no idea what is causing this error.
$error returns 1

My code:
my $dbh = DBI->connect("DBI:mysql:$db:$host", $user, $pw) || die; my $sql; my $sth; if($ENV{'REQUEST_METHOD'} eq 'GET') { my $daten; $daten = $ENV{'QUERY_STRING'}; my @formularfelder = split(/&/, $daten); my @formular = (); my $i=0; foreach my $feld (@formularfelder) { (my $name, my $value) = split(/=/, $feld); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/<!--(.|\n)*-->//g; $formular[$i] = $cgi->escapeHTML($name); $i++; $formular[$i] = $cgi->escapeHTML($value); $i++; } if(!defined $formular[0] || $formular[0] ne "dl" || ! defined $for +mular[1] || $formular[1] !~ /^\d+$/) { Navi::print_navi(": Nice try... :"); print qq{<div id="category">[ NICE TRY ]</div>}; print "<b>Nice try...</b>"; } else { $sql = qq{select p.category as category, p.titel as titel, p.b +eschreibung as beschreibung , c.werbung as werbung from movie_project +s as p join movie_categories as c on c.id = p.category WHERE p.id = ? +}; $sth = $dbh->prepare($sql) or die "Error: $DBI::errstr"; my $error = $sth->execute($formular[1]) or die "Error: $DBI::e +rrstr"; print "$error\n"; while (my $ergebnis = $sth->fetchrow_hashref()) {

In reply to DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at by Digioso

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.