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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't use string ("query") as a HASH ref

Status
Not open for further replies.

JimJx

Technical User
Feb 16, 2001
202
0
0
US
HI all, I am getting the error "Can't use string ("query") as a HASH ref while "strict refs" in use at /usr/lib/perl5/site_perl/5.8.8/Data/Pager.pm line 30."

with the following code (The area I think is causing the problem is red...):

This is driving me batty, any and all suggestions greatly appreciated.....

Jim


Code:
my $query=CGI->new();
my $count=0;

   my $get_data_sub = sub {
       my (@return_array,@data);
      
my $dbname	= "DBI:mysql:farthing_valleyweb";
my $dbusername	= "farthing_farthin";
my $dbpassword	= "ginajim";

my $dbHandle = DBI->connect($dbname, $dbusername, $dbpassword)
    or die "Can't connect: ", $DBI::errstr;
    $dbh->{RaiseError} = 1;

my $stmtHandle = $dbHandle->prepare('select * from valley where category like "Real Estate" LIMIT 3,3;');

$stmtHandle->execute();

       while(@data=$stmtHandle->fetchrow_array())
       {
	   push(@return_array, [@data]);
       }
      
       $stmtHandle->finish();
       $dbHandle->disconnect();
       
       return \@return_array;
   };

[COLOR=red]
   my $pager = Data::Pager->new(query=>$query,
                  get_data_callback => $get_data_sub,
                  rows => 11,
                  page_size =>5
		  );
[/color]

print "Content-Type: text/html\n\n";
print $pager->output;
 
Are you sure this is a MySQL problem? Looks as if you are in the wrong forum

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top