I am using DBI for the first time and am able to use fetchrow_array without any problems. It returns data as I would expect.
My problem arises when I attempt to use fetchrow_hashref. This does not appear to work correctly. I am using Win2K with an Access db.
I have gone through piles of other examples on this site and others, but still no luck - is it my code? am I blind and missing something??use DBI; use DBD::ODBC; my $DSN = 'perltest'; my $dbh = DBI->connect("dbi:ODBC:$DSN", '','') || die "$DBI::errstr\n" +; my $sql; # there are three rows that match this select statement $sql = "SELECT * FROM contacts WHERE phone = '8675309'"; $sth = $dbh->prepare($sql); $sth->execute; # this works fine as it displays the first row of data @row = $sth->fetchrow_array; print "@row<br>\n"; # this does not work - displays a blank line $hashrow = $sth->fetchrow_hashref; print "$hashrow{phone} <br>\n"; $sth->finish(); $dbh->disconnect();
Any help you could offer would be appreciated
-Jeff
In reply to DBI and fetchrow_hashref by jeff867
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |