Take a look again at your "or die" part of the connect string-  you're
using another "my," which is probably going to screw up the scoping of
$dbh.  So, you might NOT be connecting, but you'd never know it because
of that extra "my".

I usually do my connect strings thusly, don't know if it's the best
method, but it seems to work:

my $dbh=DBI->connect() or die(DBI->errstr());


-DJCP


On Sun, 2002-04-28 at 12:08, Mikey Deruki wrote:
> 
> Yes, I am running under strict.
> 
> Here is the connect string:
> 
> my $dbh = DBI->trace(1);
> $dbh = DBI->connect( 'DBI:mysql:makeout:192.168.1.102', $user, $password, 
> {PrintError => 1, RaiseError => 1} ) or die my $dbh->errstr;
> print STDERR "DBH=".Dumper($dbh);
>         my $sth = $dbh->prepare("select username,email,aim from user where 
> gender_id = 1") || die my $sth->errstr;
>         $sth->execute ||  die $sth->errstr;
> 
> This is the first mod_perl thing on this server that I've written.
> 
> Thanks,
> 
> 
> 
> >From: Dan Collis Puro <[EMAIL PROTECTED]>
> >To: Mikey Deruki <[EMAIL PROTECTED]>
> >Subject: Re: [Boston.pm] Perl DBI mysql question
> >Date: 28 Apr 2002 12:02:40 -0400
> >
> >Are you running under strict?
> >
> >Can we see the relevant sections of code?
> >
> >Your db connection works for other applications on the same server
> >running under mod_perl?
> >
> >-DJCP
> >
> >
> >On Sun, 2002-04-28 at 11:43, Mikey Deruki wrote:
> > >
> > >
> > > I have a mod_perl module that is trying to connect to a mysql DB via 
> >DBI.
> > > The connect string is not dying/erroring out.  I do have an "... or die"
> > > clause after it.  Yet on the next line when I try to prepare my select
> > > statement I get this in the error log:
> > >
> > > [Sun Apr 28 10:40:24 2002] [error] Can't call method "prepare" on an
> > > undefined value at /etc/httpd/lib/perl/MOC/Display.pm line 42.
> > >
> > > I turned on DBI Trace and get this as well...
> > >
> > >     DBI 1.21-nothread dispatch trace level set to 1
> > >     Note: perl is running without the recommended perl -w option
> > >     -> DBI->connect(DBI:mysql:makeout:192.168.1.102, moc, ****,
> > > HASH(0x81bf670))
> > >     -> DBI->install_driver(mysql) for linux perl=5.006001 pid=31443 
> >ruid=48
> > > euid=48
> > >        install_driver: DBD::mysql version 2.1014 loaded from
> > > /usr/lib/perl5/site_perl/5.6.1/i386-linux/DBD/mysql.pm
> > >     <- install_driver= DBI::dr=HASH(0x810f8cc)
> > >     <- connect= DBI::db=HASH(0x81f5900) at DBI.pm line 471
> > >     <- STORE('RaiseError' 1 ...)= 1 at DBI.pm line 513
> > >     <- STORE('PrintError' 1 ...)= 1 at DBI.pm line 513
> > >     <- STORE('AutoCommit' 1 ...)= 1 at DBI.pm line 513
> > >     <- connect= DBI::db=HASH(0x81f5900)
> > > DBH=$VAR1 = undef;
> > > [Sun Apr 28 10:40:24 2002] [error] Can't call method "prepare" on an
> > > undefined value at /etc/httpd/lib/perl/MOC/Display.pm line 42.
> > >
> > >     <- DESTROY= undef
> > >
> > >
> > > The DBH=$VAR1  line is a Data::Dumper print statement to STDERR.  Any
> > > thoughts or suggestions on how to attempt the debug process?
> > >
> > > Thanks,
> > >
> > > Mike
> > >
> > > _________________________________________________________________
> > > Get your FREE download of MSN Explorer at 
> >http://explorer.msn.com/intl.asp.
> > >
> >
> >
> 
> 
> 
> 
> _________________________________________________________________
> Join the world�s largest e-mail service with MSN Hotmail. 
> http://www.hotmail.com
> 


Reply via email to