Hi I am just messing around with Perl DBI/Apache and I can't seem to understand this problem.  Right now I am just trying to write a simple CGI perl script that just displays a mysql query.  I am using this code...
 
#!/usr/bin/perl -w
 
use DBI;
use CGI qw(fatalsToBrowser);
 
print CGI::header();
print "<title>Testing</title>";
print "<h1>Teams list</h1><br>";
 
my $dbh = DBI->connect("dbi:mysql:hello:localhost:3306", "root", "xxxx");
my $sth1 = $dbh->prepare("select * from team1");
 
$sth1->execute();
while(my $team = $sth1->fetchrow_array()){
 print "$team<br>\n";}
 
$dbh->disconnect;
 
----------------------------------------------
Now when I run the file from a shell it queries the database properly and everything prints out fine.  The problem is when I put this file in cgi-bin and try to execute it via www I am getting an error and this is what the apache error_log is saying...
 
[Sat Sep 21 18:21:08 2002] [error] [client 10.0.0.2] Premature end of script headers: football.pl
[Sat Sep 21 18:21:08 2002] [error] [client 10.0.0.2] Can't locate loadable object for module DBI in @INC (@INC contains: /usr/local/lib/perl5/5.8.0/i686-linux /usr/local/lib/perl5/5.8.0 /usr/local/lib/perl5/site_perl/5.8.0/i686-linux /usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl .) at /usr/local/lib/perl5/site_perl/5.8.0/i686-linux/DBI.pm line 243
[Sat Sep 21 18:21:08 2002] [error] [client 10.0.0.2] BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.8.0/i686-linux/DBI.pm line 243.
[Sat Sep 21 18:21:08 2002] [error] [client 10.0.0.2] Compilation failed in require at /usr/local/apache2/cgi-bin/football.pl line 3.
[Sat Sep 21 18:21:08 2002] [error] [client 10.0.0.2] BEGIN failed--compilation aborted at /usr/local/apache2/cgi-bin/football.pl line 3.
------------------------------------------------
Regular perl scripts (non DBI) run fine so I don't know if there is something special didn't set up.  I am running the latest stable apache2 and mod_perl.  I installed Apache::DBI as well and the README says "For Apache::DBI you need to enable the appropriate call-back hooks when making mod_perl: perl Makefile.PL PERL_CHILD_INIT=1 PERL_STACKED_HANDLERS=1."  I tried that but the latest mod_perl doesn't recognize those parameters.  Maybe that could have something to do with it? 
 
I am sorry if this is an obvious answer (IE I didn't read the FAQs thoroughly enough) but I am new to this stuff and some of that info can be overwhelming at times.  Also I hope this is the right mailing list because it seems to be a mod_perl related problem....
 
Thanks,
 
Rich

Reply via email to