I've got quite a mess here.
I have a new Windows 2000 Server, running IIS. I've installed PHP manually (as well as using the php.net binaries). I have edited the php.ini file to point the extension_dir to the correct location. I have installed the Oracle client, as well as SQL Plus.
I also have an UNIX box, running the actual Oracle db.
No matter what I try, I cannot connect to the DB through a PHP script. I have now tried 3 different approaches (scripts) with no luck. The scripts, along with their errors, are below.
As a side note, when I try to uncomment oci8.dll or oracle.dll in the php.ini file, i can no longer get PHP to function. it just sits there. Perhaps this is the real problem?
Lastly, when I try to connect to the Oracle DB from the Windows server through SQL Plus, it works great.
Code try number 1:
$dsn = 'will';
$dbuser = 'plsowner';
$dbpass = 'skypiepls4';
$dbname = 'sky';
function dbConnect() {
global $dsn, $dbuser, $dbpass;
$dbcnx = odbc_connect($dsn, $dbuser, $dbpass)
or die('The site database appears to be down..');
if ($db!='')
die('The site database is unavailable.');
return $dbcnx;
}
dbConnect($dbname); ?>
Error: PHP Warning: odbc_connect(): SQL error: [Microsoft][ODBC driver for Oracle][Oracle]ORA-12154: TNS:could not resolve service name, SQL state 08001 in SQLConnect in C:\Inetpub\wwwroot\projects\PLS\PHP_DEV\db.php on line 12
Try number two:
dl('php_oracle.dll');
//dl('php_oci8.dll');
putenv("ORACLE_SID=pie");
if ($c=ocilogon("plsowner", "skypiepls4")) {
echo "Successfully connected to Oracle.\n";
OCILogoff($c);
} else {
$err = ocierror();
echo "Oracle Connect Error " . $err[text];
} ?>
Error: (times out)
Try number 3:
$odbc=odbc_connect('sky', 'plsowner', 'skypiepls4') or die("could not connect to odbc db:".odbc_error()."<P>");
function odbc_fetch_array($result, $rownumber=-1) {
if (PHP_VERSION > "4.1") {
if ($rownumber < 0) {
odbc_fetch_into($result, $rs);
} else {
odbc_fetch_into($result, $rs, $rownumber);
}
} else {
odbc_fetch_into($result, $rownumber, $rs);
}
$rs_assoc = Array();
foreach ($rs as $key => $value) {
$rs_assoc[odbc_field_name($result, $key+1)] = $value;
}
return $rs_assoc;
}
?>
Error:
could not connect to odbc db:S1009
PHP Warning: odbc_connect(): SQL error: [Oracle][ODBC][Rdb]Invalid argument value., SQL state S1009 in SQLConnect in C:\Inetpub\wwwroot\projects\PLS\PHP_DEV\odbc.php on line 2
Help!