PHP and Oracle 8 - IT WORKS!!

admin

Administrator
Staff member
Hi!

After trying all tips and tricks on how to get ORACLE and PHP work together I finally got it!
In about 60% of tests (i.e. PHP script calls) the connection to the ORACLE server worked. Now it works 1005 :)

WWW-Server:
Redhat-Linux 7, Apache 1.3.14, PHP 4.0.3pl1, ORACLE Client 8i

DB-Server:
Windows 2000, ORACLE 8i

tnsnames.ora:
>>>
INTRANET.MYDOMAIN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = ( PROTOCOL = TCP) (HOST = merkur) (PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = intranet.mydomain)
)
)
<<<

sqlnet.ora:
>>>
NAMES.DEFAULT_DOMAIN = mydomain
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
<<<

Simply change "mydomain" to your domain name, e.g. "world" and "merkur" to your DB server name.

These are the only entries in these two files!

I also used SetEnv in httpd.conf to set TNS_ADMIN, ORACLE_HOME, ORACLE_OWNER and ORA_NLS33, although I`m sure TNS_ADMIN and ORACLE_HOME would be enough.

Try this:
putenv("ORACLE_HOME=/usr/local/oracle");
putenv("TNS_ADMIN=/usr/local/oracle/network/admin");
$db = "intranet.mydomain";
$connID = OCILogon("system", "manager", $db);
if ($connID > 0) {
echo "Connected to Oracle!";
}
else {
echo "Connection Failed!";
}


After one day of hard work, it works finally - great :)


Regards,
Sascha
 
Back
Top