Hi
I am having a bad time with connection of php and oracle. I m using PEAR for the same. OCI8 extension have been enabled and it shows in phpinfo();
but when i use DB/MDB2 to connect it simply returns with wierd errors.
While i was browsing, i found this script.
print_r ($_ENV['Path']);
print "<br>";print "<br>";print "<br>";
print "<br>path:".$_ENV['PATH'];
print "<br>oracle_home: ".$_ENV['ORACLE_HOME']."<br>";
print "<br>";
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
$process = proc_open("sqlplus user/pwd@service", $descriptorspec, $pipes);
if (is_resource($process)) {
fwrite($pipes[0], "select sysdate from dual;\n");
fclose($pipes[0]);
while(!feof($pipes[1])) {
echo fgets($pipes[1], 1024);
}
fclose($pipes[1]);
$return_value = proc_close($process);
echo "command returned $return_value\n";
}
putenv("NLS_LANG=ENGLISH_UNITED KINGDOM.WE8ISO8859P1");
if (!$conn = OCILogon("icare","icare","cogent")) {
$err = OCIError();
die($err['message']);
}
print "<hr>Server Version: " . OCIServerVersion($conn) . "<hr>";
if (!$stmt = OCIParse($conn,"
select sysdate from dual
")) {
$err = OCIError();
die($err['message']);
}
if (!OCIExecute($stmt)) {
$err = OCIError();
die($err['message']);
}
while (OCIFetchInto($stmt, $row, OCI_ASSOC+OCI_RETURN_NULLS)) {
print_r($row);
}
OCIFreeStatement($stmt);
OCILogoff($conn);
which produces output as below:
path:
oracle_home:
SQL*Plus: Release 9.0.1.0.1 - Production on Sat Oct 6 13:28:37 2007 Copyright 2001 Oracle Corporation. All rights reserved. ERROR: ORA-12500: TNS:listener failed to start a dedicated server process Enter user-name: SP2-0306: Invalid option. Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}] where ::= [/][@] | / Enter user-name: command returned 0 PHP Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries in C:\Inetpub\wwwroot\cgl\includes\inc.php on line 32 PHP Warning: ocierror() [function.ocierror]: OCIError: unable to find error handle in C:\Inetpub\wwwroot\cgl\includes\inc.php on line 33
Do i need to add Oracle_Home. Plz advise as i have to move this to production server.
Please help. I am really stuck.
Thanks