can't connect to database

admin

Administrator
Staff member
Hi, if I run the enclosed script which I downloaded from the net, It works ok from the NT command line but fails from within my apache webserver, complaining with the following from within the error.log. What I can understand is what is different that it connects to the database from the command line but fails from within apache ???

Premature end of script headers: c:/program files/apache group/apache/cgi-bin/ex11-4.pl
DBI->connect(host=cdcaix003;sid=MRF) failed: N?(DBD: login failed, check your config, e.g. ORACLE_HOME/bin on your PATH etc) at c:\PROGRA~1\APACHE~1\apache\cgi-bin\ex11-4.pl line 12
can't connect to DBI:Oracle:host=cdcaix003;sid=MRF: N?(DBD: login failed, check your config, e.g. ORACLE_HOME/bin on your PATH etc)

script
======

#!d:\perl\bin\perl -w
# example 11-4

use strict;
use DBI;
use CGI qw(:standard);

my $data;

my $db = "DBI:Oracle:host=10.3.0.12;sid=MRF",;

my $dbh = DBI->connect($db,'oramrf/oramrf') or
die " can't connect to $db: $DBI::errstr\n";

my $sql = "SELECT sku, name, descr, stock, price FROM products";
my $sth = $dbh->prepare($sql);

$sth->execute;

print header;

print <<HTML;

<HEAD><TITLE>Example 11-4 Output</TITLE></HEAD>
<BODY>
<CENTER>
<TABLE BORDER="1" CELLSPACING="0">
<TR>
<TD><B>SKU</B></TD>
<TD><B>Product</B></TD>
<TD><B>Description</B></TD>
<TD><B># in Stock</B></TD>
<TD><B>Price</B></TD>
</TR>
HTML

while($data = $sth->fetchrow_arrayref){
print qq(<TR>\n);

foreach(@$data){
print qq(<TD>$_</TD>\n);
}

print qq(</TR>\n);
}

print qq(</TABLE></CENTER></BODY>);

$dbh->disconnect;

print qq(</TABLE></CENTER></BODY>);
 
Back
Top