in reply to Help on fetchrow_hashref!
I would strongly suggest adding some additional tests to your routine. For example, if your placeholder binding fails (implicitly performed in your execute), your script will continue on since your don't check if your execute was successful. For example, I would suggest changing $sth->execute($lname,$username); to $sth->execute($lname,$username) or die "Execute failed: ", $dbh->errmsg; As well, to test if the row existed after a successful query, how about
if (my $hashref = $sth->fetchrow_hashref) { %info = %{$hashref}; } else { die "lname, username combo did not match any records"; }
Update: Typo fixed, thanks wfsp.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help on fetchrow_hashref!
by Anonymous Monk on Nov 09, 2010 at 19:01 UTC | |
by Corion (Patriarch) on Nov 09, 2010 at 19:11 UTC | |
by Anonymous Monk on Nov 09, 2010 at 19:30 UTC | |
by Corion (Patriarch) on Nov 09, 2010 at 20:29 UTC | |
by Anonymous Monk on Nov 09, 2010 at 20:41 UTC | |
|