Re: Oracle connectivity proble with PHP4
| From: | Erol Ozcan | Date: | Wed, 16 Aug 2000 08:11:39 +0000 |
| Subject: | Re: Oracle connectivity proble with PHP4 | ||
| References: | 1 | Groups: | php.db php.dev |
| Request: | Send a blank email to php-db+get-2079@lists.php.net to get a copy of this message | ||
Nee Choong Moo wrote:
> Hi,
> My name is Nee Choong. I'm using apache 1.3.12, php4, RH6-Linux and
> oracle 8i client. I have tried compiling both static amd mod of php support
> for apache with oci8. I was able to connect and retrieve data from a remote
> oracle 8i server in cgi mode of php(as an executable) but failed to do so
> when running the same script using apache with php support (both methods
> mentioned earlier failed). The error no is ora 12154. I've tried setting 3
> major environment variable for oracle, ORACLE_HOME, ORACLE_SID and TNS_ADMIN
> to proper paths using both SenEnv in the httpd.conf and also coding the
> variables in apachectl file and was able to pull those from the environment
> of the webserver by using the provided cgi-bin/printenv cgi script from
> apache but still the php script failed to conect to the server.
> I've read all the postings in faqts but still cant find a solution. I've
> also tried the phpinfo() function from a php file from through the webserver
> and I'm sure oci8 is installed, but one thing, the oci library version is
> not stated.
> Please Help.
> Thanks Nee Choong
I had similiar problem. Did you try to use full db name at OCILogin command?
Also check your dbhost with tnsping command. The following script could help
you.
<?php
// Script by Erol Ozcan
putenv("ORACLE_HOME=/home/oracle/app/oracle/product/8.1.6");
putenv("ORACLE_SID=light");
putenv("ORA_NLS=/home/oracle/app/oracle/product/8.1.6/ocommon/nls/admin/data");
print "<HTML><PRE>";
//OCIInternalDebug(1);
$db = "light.infotron.com.tr"; // full db name
$conn = OCILogon("scott","tiger",$db);
$stmt = OCIParse($conn,"select empno, ename from emp");
OCIDefineByName($stmt,"EMPNO",&$empno);
OCIDefineByName($stmt,"ENAME",&$ename);
OCIExecute($stmt);
?>
<table border=1>
<tr><td>number</td><td>empno</td><td>ename</td></tr>
<?
$i=1;
while (OCIFetch($stmt)) {
echo "<tr><td>$i</td><td>$empno</td>";
echo "<td>".$ename."</td>"."</tr>";
$i++;
}
echo "</table>";
OCIFreeStatement($stmt);
OCILogoff($conn);
?>
Erol Ozcan