Oh wizened perl monks... help me!
I've been poking around online to see if I can figure out what the error DBD::mysql::st fetchrow_array failed: fetch() without execute(). The first results told me that people had no clue, then I stumbled onto a response to a similar error that had happened here. The solution that time seemed to be simply removing a line of $sth->finish(); but unfortunately that's no help. The other thought is that the DB connection is just dying partway through. The second thing I can't figure out is why I get the DBD::mysql::st fetchrow_array failed: fetch() without execute() twice. ...in any case, any advice that can be offered would be very helpful.
Code Snippet:
if ($DEBUG) { print "Connected. \n";}
#populate names:
if ($DEBUG) { print "Populating names \n";}
my $sth = $dbh->prepare("SELECT distinct name FROM storeCategories");
$sth->execute();
my $count = 0;
while (my @names = $sth->fetchrow_array){
if ($DEBUG) { print "inputting $names[0] \n";}
$sth = $dbh->prepare("INSERT INTO names (name) VALUES (?)");
$sth->execute($names[0]);
$count++; #THIS IS LINE 27.
}
if ($DEBUG) { print "done with names inserted $count names \n";}
Gives output:
Connected.
Populating names
inputting Sample Kits
DBD::mysql::st fetchrow_array failed: fetch() without execute() at *******.pl line 27.
DBD::mysql::st fetchrow_array failed: fetch() without execute() at *******.pl line 27.
DB returns:
296 rows in set (for that same query).
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.