This is driving me crazy... is there anything special I need to do when
using DBI (DBD::MySQL) with mod_perl. A script that works just fine sans
mod_perl dies with error 500 (Internal Server Error) when mod_perl is
enabled for that file type:
Web Server: Apache/1.3.19(Win32) mod_perl/1.24_01 on a Windows 2000
server -- connecting to a MySQL 3.23.38-nt DB-server.
Sample of httpd.conf:
# BEGIN MOD_PERL CONFIG
LoadModule perl_module modules/ApacheModulePerl
ScriptAlias /perl-bin/ "perl-bin/"
PerlSendHeader On
<Location /perl-bin>
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
</Location>
<Files *.pl>
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
</Files>
<Files *.cgi>
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
</Files>
# END MOD_PERL CONFIG
Error Log entry:
[Tue May 22 00:13:09 2001] nul: DBI->connect failed: Can't connect to MySQL
server on 'localhost' (10061) at e:/pad/htdocs/internet/system/frontpage.cgi
line 29
[Tue May 22 00:13:09 2001] [error] Can't call method "prepare" on an
undefined value at e:/pad/htdocs/internet/system/frontpage.cgi line 30.
Perl Code:
use DBI();
$driver = "mysql";
$dsn = "DBI:$driver:database=shapeshifter;host=localhost";
$dbh = DBI->connect($dsn, dbusrname, dbpassword);
my $sth = $dbh->prepare("SELECT * FROM frontpage");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
$body .= qq~Found a row: id = $ref->{'serial_number'}, name =
$ref->{'position'}<BR>~;
}
$sth->finish();
$dbh->disconnect();
Any help appreciated. I have RTFMs but I can't reach any conclusions about
contention between mod_perl and MySQL...
Kindest regards,
Jonathan M. Hollin
Digital-Word.com