Here are my files:

httpd.conf -

    Alias /perl/ "/usr/local/www/perl/"
        PerlModule Apache::DBI
        PerlRequire /usr/local/www/startup.pl
        PerlModule Apache::Registry
        PerlModule Apache::DBI
        PerlSetEnv PERLDB_OPTS "NonStop=1 LineInfo=/tmp/db.out AutoTrace=1 frame=2"
        PerlModule Apache::DB
    <Location "/perl">
                PerlFixupHandler Apache::DB
                SetHandler perl-script
                PerlHandler Apache::Registry
        Options +ExecCGI
        AllowOverride None
        Order allow,deny
        Allow from all
                PerlSendHeader on
    </Location>

startup.pl -

use strict;
$ENV{MOD_PERL} or die "not running under mod_perl!";
use Apache::DBI ();
use Apache;
use Apache::Cookie;
use Apache::Request;
use Carp();
$SIG{__WARN__} = \&Carp::cluck;
sub My::ProxyRemoteAddr ($) {
  my $r = shift;
  return unless ($r->connection->remote_ip eq "127.0.0.1");
  if (my ($ip) = $r->header_in('X-Forwarded-For') =~ /([^,\s]+)$/) {
    $r->connection->remote_ip($ip);
  }
  return ;
}
Apache::DBI->connect_on_init
        ("dbi:Pg:dbname=jewelry",'','',
                {
                        PrintError => 1,
                        RaiseError => 0,
                        AutoCommit => 1,
                });

my programm -

use strict;
use Apache::DBI;
$Apache::DBI::DEBUG = 2;
use Apache;
use Carp();
local $SIG{__WARN__} = \$Carp::cluck;
my $dbh;
$dbh = DBI->connect("dbi:Pg:dbname=jewelry", '', '');
my $r=shift;
$r->send_http_header('text/html');
my $sql = "select * from tbl_category";
my $sth = $dbh->prepare($sql);
my $rs = $sth->execute();
my @rs;
while(@rs = $sth->fetchrow_array){
        $r->print("$rs[0]\t$rs[1]\n");
}
$sth->finish;
$dbh->disconnect;

and httpd-error.log -

[Sat May  5 16:35:28 2001] [notice] FastCGI: process manager initialized (pid 14154)
[Sat May  5 16:35:29 2001] [notice] Apache/1.3.19 (Unix) mod_fastcgi/2.2.10 
mod_perl/1.25
configured -- resuming normal operations
Default die handler restored.
14156 Apache::DBI             need ping: yes
14156 Apache::DBI             new connect to 
'dbname=jewelryPrintError=1AutoCommit=1'
[Sat May  5 16:39:27 2001] [error] Not a subroutine reference at
(eval 225)[/usr/local/lib/perl5/site_perl/5.6.1/i386-freebsd/Apache/Registry.pm:177] 
line 73.

Line 73 is "my $rs = $sth->execute();"

So, does anybody understand what's going on?
Why my programm doesn't work?
It works as plain perl script perfect.
And Apache::Session::Store::Postgres works perfect - it mean, mod_perl
works with Postgres.

Thank's,

my best regards,
-----------------------------
Grigoriy G. Vovk

Reply via email to