Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting rows from mysql database

Status
Not open for further replies.

Davc

Technical User
Apr 30, 2002
8
IE
I get the following error message:

######
Can't locate DBI object method "fetchrow_hashref" via package "DBD::mysql::st" at C:\httpd\CGI-BIN\viewfiles.pl line 34.
#######

When I execute the following code.
Can anyone help me out?

*****************************************
sub Get_Descriptions{
my $DBH = DBI->connect("DBI:mysql:files", "david", "");

my $sth_fetch =
$DBH->prepare( qq(SELECT * FROM table01) ) or die $DBH->errstr;

$sth_fetch->execute();
print "$sth_fetch \n";
print "got to here \n";

while( $ptr = $sth_fetch->fetchrow_hashref ){
Print_Row($ptr);
}
}

 
The line containing:

**********
while( $ptr = $sth_fetch->fetchrow_hashref ){

**********

is giving all the bother.


 
what is qq?



- qq(SELECT * FROM table01)
+ "SELECT * FROM table01"

my $ptr
before it's used
 
I declared my $ptr before its used and I'm still confronted with the same error message:

**********
Can't locate DBI object method "fetchrow_hashref" via package "DBD::mysql::st" at C:\httpd\CGI-BIN\viewfiles.pl line 36.
**********

qq is used in Perl and is the same as "". It means that the following string should be interpolated
 
Have you tried the offending line with explicitly telling perl you're calling a function?

while( $ptr = $sth_fetch->fetchrow_hashref() ){
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top