I'm having trouble getting a script that uses the DBI module to work under
mod_perl. It works fine at the command line or as a normal cgi script.
I've included the code below. When I try to run from the browser under
mod_perl the only only output is the first portion of HTML. I've tried
looking in the server error_log, and unfortunately no error messages are
generated. I've tried putting the connect() method ahead of the initial
html, in which case a get a "document contained no data" error from the
browser. I'm really banging my head against the wall with this one. Any
help would be much appreciated.
Thanks,
Joe Grastara
#!/usr/local/bin/perl
use strict;
use DBI;
use CGI
qw(:standard);
###Set Local Environmental Variable for Oracle###
$ENV{"ORACLE_HOME"} = "/db/";
###Print out some HTML###
print <<HTML_1;
Content-type: text/html\n
<html> <head> <title>Ph Lookup</title> </head> <body bgcolor=white>
HTML_1
my $dbh =DBI->connect("dbi:Oracle:rcr4","grastj01","joe2",{PrintError=>1});# or die
"can't connect to Oracle database: $DBI::errstr\n";
my $sth = $dbh->prepare("SELECT * FROM PH.NAME where LAST_NAME LIKE
'Grastara'");
$sth->execute();
my ($row, $array_ref, @data, $i);
$array_ref = $sth->fetchall_arrayref();
foreach $row (@$array_ref) {
@data = @$row;
}
foreach $i (@data) { print "$i<br>"; }
print <<HTML_2;
</body> </html>
HTML_2