Please forgive what may be an often encountered problem, but
I haven't found anything helpful in the archive or other online sources.

I am encountering a problem that I can't figure out when trying to access
a Mysql database from with mod_perl using Tie::DBI.  I am having
similar problems when I use straight DBI as well.  I eventually wish
to use Apache::DBI for a persistent connection, but I can't get this
to work first.

Here's the particulars:

Problem: programs that try to access the database just stop, no error in
         in logs.  Logging statements or print statements after an attempted
      access to the db are never executed.

http.conf contains the following entry (otherwise everything is standard)
(Placed at beginning of httpd.conf if placement location matters)

# Load mod_perl specific stuff
<IfModule mod_perl.c>
Include conf/perl.conf
</IfModule>

perl.conf contains the following:

PerlRequire             conf/startup.pl
PerlFreshRestart        On

<Location /test>
 SetHandler     perl-script
 PerlHandler    Apache::test
</Location>

My startup.pl contains the following:

#!/usr/bin/perl

BEGIN {
     use Apache ();
     use lib Apache->server_root_relative('lib/perl');
}

# commonly used modules
use Apache::Constants ();
use CGI qw(-compile :all);
use CGI::Carp ();

##
1;

<apache-root>/lib/perl/Apache/test.pm contains:

package Apache::test;
use strict;
use CGI qw(:standard);
use Apache::Constants qw(:common);
use Tie::DBI;
sub handler {
        my $r = shift;
     $r->log_error("Before Tie");
        tie my %DB, 'Tie::DBI', {
                'db'            => 'mysql:userdb',
                'table'         => 'Users',
                'key'           => 'UserName',
                'user'          => 'uuuuuuu',
                'password'      => 'ppppppp',
        } or return SERVER_ERROR;
     $r->log_error("After Tie");
        print   header(),
                start_html(     -title  => 'Test' ,
                                -bgcolor=> 'white');
        while ( my ($key,$value) = each %DB ) {
                print "Key=$key \n";
                foreach (sort keys %$value) {
                        print "\t$_ => $value->{$_}\n";
                }
        }
        print   end_html();
}
1;
__END__

I start and stop apache with apachectl.  I then point my browser to

http://myserver/test

and nothing happens.  Browser pops up a dialog saying: "Document contains
no Data..." and the only entry is the "Before Tie" in the apache error log.
No errors in the mysql error log either.

What am I missing???

Thanks in advance for the help.

Todd


Reply via email to