You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by John Mulkerin <jm...@home.com> on 2001/03/20 03:37:23 UTC

Problem with Tie::DBI and DBI in modperl

O mighty Wizards please help if you can:
 I'm trying to use the plain vanilla TicketTool.pm from O'Reilly's mod perl
book, Apache Modules with Perl and C.  It uses Tie::DBI to create a hash of
the mysql connection.   When I run just the authentication subroutine with
Perl -d "authenticate.pm" it runs fine.  Whe I run it as part of the web
server, it fails in the connect statement in the Tie:DBI routine.   I've
been struggling for months on this.  Could anyone help?  I figured maybe I
have a "use statement wrong but I've tried more combos than I'll ever
remember.

John Mulkerin

Use lines from TicketTool.pm:
     package Apache::TicketTool;     use strict;    use Tie::DBI ();    use
CGI::Cookie ();    use MD5 ();    use LWP::Simple ();    use Apache::File
();    use Apache::URI ();  use DBI;

Problem line in script:
            tie my %DB, 'Tie::DBI', {
                'db' => 'mysql:its',
                'table' => 'passwd', 'key' => 'username',
                'user' => 'helpman', password => 'secret01',
        } or print "Couldn not open database \n";

Problem line in Tie::DBI
sub connect {
  my ($class,$dsn,$user,$password,$options) = @_;
return DBI->connect($dsn,$user,$password,$options);

Startup.pl (from apache conf directory)
BEGIN {
        use Apache ();
        use lib Apache->server_root_relative('libexec/perl');
}
# Commonly used modules
use Tie::DBI ();
use Apache::DBI ();
use Apache::Registry ();
use Apache::Constants();
use CGI qw(-compile :all);
use CGI::Carp ();

1;
~



Re: Problem with Tie::DBI and DBI in modperl

Posted by John Mulkerin <jm...@home.com>.
Searched this list, dbiusers, and a bunch more.    I'm not sure if its
something so dump it's never discussed or what.   There is no error message
returned, it just goes back to the httpd 403 error screen.   I've added a
print statement in the middle of the connect and had it print to the screen
and it looks the same rather I'm in Perl or via Mod_perl.  Here is the
result from the print: "dbi:mysql:its,helpman,secret01,HASH(0xaf798b4)"
Looks like it should work, but nothing seems to be  returned from the
"return DBI->connect($dsn,$user,$password,$options)" statement.

John

----- Original Message -----
From: "Perrin Harkins" <pe...@primenet.com>
To: "John Mulkerin" <jm...@home.com>
Cc: <mo...@apache.org>
Sent: Monday, March 19, 2001 11:34 PM
Subject: Re: Problem with Tie::DBI and DBI in modperl


> On Mon, 19 Mar 2001, John Mulkerin wrote:
> > I'm trying to use the plain vanilla TicketTool.pm from O'Reilly's mod
> > perl book, Apache Modules with Perl and C.  It uses Tie::DBI to create
> > a hash of the mysql connection.  When I run just the authentication
> > subroutine with Perl -d "authenticate.pm" it runs fine.  Whe I run it
> > as part of the web server, it fails in the connect statement in the
> > Tie:DBI routine.
>
> What is the exact error message?  Have you tried searching the mailing
> list archive for that message?  Are you using PHP in your server?
>
> - Perrin
>


Re: Problem with Tie::DBI and DBI in modperl

Posted by Perrin Harkins <pe...@primenet.com>.
On Mon, 19 Mar 2001, John Mulkerin wrote:
> I'm trying to use the plain vanilla TicketTool.pm from O'Reilly's mod
> perl book, Apache Modules with Perl and C.  It uses Tie::DBI to create
> a hash of the mysql connection.  When I run just the authentication
> subroutine with Perl -d "authenticate.pm" it runs fine.  Whe I run it
> as part of the web server, it fails in the connect statement in the
> Tie:DBI routine.

What is the exact error message?  Have you tried searching the mailing
list archive for that message?  Are you using PHP in your server?

- Perrin