You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by m31 <m3...@charter.net> on 2002/07/20 02:18:30 UTC
need mysql and mod_perl advice
I've been trying to connect to mysql via mod_perl and have been getting
errors. Here is a snippet from the code:
.....
sub handler {
my $r = shift;
my $dbase = $r->dir_config( 'DBNAME' );
my $user = $r->dir_config( 'DBUSER' );
my $pass = $r->dir_config( 'DBPASS' );
my $dbh = DBI->connect( $dbase, $user, $pass, { #
line no. 16
RaiseError => 1,
AutoCommit => 1,
PrintError
=> 1 }) or die $DBI::errstr;
I have DBNAME, DBUSER, DBPASS set correctly with PerlSetVar in my config
file,
the error says:
[error] Can't call method "connect" on an undefined value at
/Library/www/lib/perl/Apache/DBILogger.pm line 16
during global destruction.
I am use() 'ing all the required modules and I'm able to print $dbase,
$user, $pass to screen so where is the undefined value??
Re: need mysql and mod_perl advice
Posted by m31 <m3...@charter.net>.
Perrin Harkins wrote:
> Jonathon M. Robison wrote:
>
>> Quite possibly it's the use of $DBI::errstr.
>>
>> I had a similar problem a few years ago and I recall that it was not
>> the actual "my $dbh", but instead wall the "or $DBI" part that caused
>> it. Maybe the $DBI routines don't include the errstr method. Perhaps
>> that is only there for the created object?
>
>
>
> $DBI::errstr is a global variable that is always accesible from
> anywhere. It may not have anything in it, but you will always be able
> to read it.
>
>
>>> I've been trying to connect to mysql via mod_perl and have been
>>> getting errors. Here is a snippet from the code:
>>>
>>> .....
>>> sub handler {
>>> my $r = shift;
>>> my $dbase = $r->dir_config( 'DBNAME' );
>>> my $user = $r->dir_config( 'DBUSER' );
>>> my $pass = $r->dir_config( 'DBPASS' );
>>> my $dbh = DBI->connect( $dbase, $user, $pass,
>>> { # line no. 16
>>> RaiseError
>>> => 1,
>>> AutoCommit => 1,
>>> PrintError
>>> => 1 }) or die $DBI::errstr;
>>>
>>> I have DBNAME, DBUSER, DBPASS set correctly with PerlSetVar in my
>>> config file,
>>> the error says:
>>> [error] Can't call method "connect" on an undefined value at
>>> /Library/www/lib/perl/Apache/DBILogger.pm line 16
>>> during global destruction.
>>
>>
>
> That message means this error happened during a shutdown of the Perl
> interpreter. You don't do that on every request, do you?
>
> - Perrin
>
>
>
No, It doesn't run every request, I'm actually just testing how I would
connect to mysql via mod_perl, to debug and learn the differences
between mod_perl and regular cgi.
I got the connection to work by making a more basic connection, but now
I get different errors. It appears that the same symbol is defined twice
and returns a "multiple definitions of symbol" error between mod_perl
and the php module:
dyld: /usr/sbin/httpd multiple definitions of symbol __dig_vec
/usr/libexec/httpd/libphp4-4.1.2.so definition of __dig_vec
/Library/Perl/darwin/auto/DBD/mysql/mysql.bundle definition of __dig_vec
So it appears that the same symbol s defined twice, one in the
mysql.bundle and one in mod_php. Does any one know if "__dig_vec" is
just an Darwin/OSX thing and is there a work around besides disabling
the php module?? Sorry if this may not be a mod_perl specfic thing but
it effects my capabilities with mod_perl.
Re: need mysql and mod_perl advice
Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hi all,
On Sat, 20 Jul 2002, Perrin Harkins wrote:
> Jonathon M. Robison wrote:
>
> > Quite possibly it's the use of $DBI::errstr.
>
> $DBI::errstr is a global variable that is always accesible
>
> >> I've been trying to connect to mysql via mod_perl and have been
> >> getting errors. Here is a snippet from the code:
> >> .....
> >> sub handler {
> >> my $r = shift;
> >> my $dbase = $r->dir_config( 'DBNAME' );
> >> my $user = $r->dir_config( 'DBUSER' );
> >> my $pass = $r->dir_config( 'DBPASS' );
> >> my $dbh = DBI->connect
> >> ( $dbase, $user, $pass,
> >> {
> >> RaiseError => 1,
> >> AutoCommit => 1,
> >> PrintError => 1
> >> }
> >> ) or die $DBI::errstr;
I think you need to set AutoCommit to 0.
73,
Ged.
Re: need mysql and mod_perl advice
Posted by Perrin Harkins <pe...@elem.com>.
Jonathon M. Robison wrote:
> Quite possibly it's the use of $DBI::errstr.
>
> I had a similar problem a few years ago and I recall that it was not
> the actual "my $dbh", but instead wall the "or $DBI" part that caused
> it. Maybe the $DBI routines don't include the errstr method. Perhaps
> that is only there for the created object?
$DBI::errstr is a global variable that is always accesible from
anywhere. It may not have anything in it, but you will always be able
to read it.
>> I've been trying to connect to mysql via mod_perl and have been
>> getting errors. Here is a snippet from the code:
>>
>> .....
>> sub handler {
>> my $r = shift;
>> my $dbase = $r->dir_config( 'DBNAME' );
>> my $user = $r->dir_config( 'DBUSER' );
>> my $pass = $r->dir_config( 'DBPASS' );
>> my $dbh = DBI->connect( $dbase, $user, $pass,
>> { # line no. 16
>> RaiseError
>> => 1,
>> AutoCommit => 1,
>> PrintError
>> => 1 }) or die $DBI::errstr;
>>
>> I have DBNAME, DBUSER, DBPASS set correctly with PerlSetVar in my
>> config file,
>> the error says:
>> [error] Can't call method "connect" on an undefined value at
>> /Library/www/lib/perl/Apache/DBILogger.pm line 16
>> during global destruction.
>
That message means this error happened during a shutdown of the Perl
interpreter. You don't do that on every request, do you?
- Perrin
Re: need mysql and mod_perl advice
Posted by "Jonathon M. Robison" <jr...@uniphied.com>.
Quite possibly it's the use of $DBI::errstr.
I had a similar problem a few years ago and I recall that it was not the
actual "my $dbh", but instead wall the "or $DBI" part that caused it.
Maybe the $DBI routines don't include the errstr method. Perhaps that is
only there for the created object?
Sorry I can't do the research to be sure of this answer - it's time for
bed for me.
--Jon R.
m31 wrote:
> I've been trying to connect to mysql via mod_perl and have been getting
> errors. Here is a snippet from the code:
>
> .....
> sub handler {
> my $r = shift;
> my $dbase = $r->dir_config( 'DBNAME' );
> my $user = $r->dir_config( 'DBUSER' );
> my $pass = $r->dir_config( 'DBPASS' );
> my $dbh = DBI->connect( $dbase, $user, $pass, {
> # line no. 16
> RaiseError => 1,
> AutoCommit => 1,
> PrintError =>
> 1 }) or die $DBI::errstr;
>
> I have DBNAME, DBUSER, DBPASS set correctly with PerlSetVar in my config
> file,
> the error says:
> [error] Can't call method "connect" on an undefined value at
> /Library/www/lib/perl/Apache/DBILogger.pm line 16
> during global destruction.
>
> I am use() 'ing all the required modules and I'm able to print $dbase,
> $user, $pass to screen so where is the undefined value??
>
>