HELP: apache+php+oracle

admin

Administrator
Staff member
I know this topic seems to pop up about once a day in the newsgroups, but I still can't find a solution to the following setup:

Apache 1.3.14 + PHP 4.0.3pl1 + Oracle 8.0.5 client on a Win95 OSR2 box, trying to access either Oracle 8.0.5 or 7.3.4 databases running on SCO or NT servers.

I tried both Oracle connection functions, OCI functions and even through ODBC. All I get is an ORA-12154 or ORA1-12203 error.

Note: the TNSNAMES.ORA files are setup correctly: I can log-in to databases by sql-plus or ping them via tnsping and tnsping80. Same applies for the ODBC connection: it has been tested using the oracle tools. My phpinfo() page appears to be right. It gives me information on oci8, oracle and ODBC.

I have read the problem might be relative to environment variables needing to be defined (do I need to do this in the registry, php or autoexec.bat ?), missing linefeed chars in the .php file(?) or a thousand other reasons, mostly being a misconfiguration of TNSnames.

Here's the guilty page:

<BODY>
<?
// AMBIENT VARIABLES FOR ORACLE
putenv("ORACLE_HOME=C:\ORAWIN95");
putenv("TNS_ADMIN=C:\ORAWIN95\NET80\ADMIN");
putenv("ORACLE_SID=MEZZITEST");

echo('<HR>Trying to connect with ORACLE methods<BR>');
$con = ora_logon("officina","officina");
if ($con)
{ print "Connected!"; }
else {
echo('<HR>Trying to connect with OCI methods<BR>');
OCIInternalDebug(1);
$con = OCILogOn("officina", "officina","mezzitest");
if ($con)
{ print "Connected!"; }
else {
echo('<HR>Trying to connect with ODBC methods<BR>');
$connessione=odbc_connect("MEZZITEST","officina","officina");
if ($connessione)
{ print "Connected!"; }
else {
print "Non Connesso!!!";
};
};
};
?>

</BODY>


and the results:

--------------------------------------------------------------------------------
Trying to connect with ORACLE methods

Warning: Oracle: Connection Failed: ORA-12154: TNS:could not resolve service name in c:\programmi\apache group\apache\htdocs\phpconnect.php on line 10

--------------------------------------------------------------------------------
Trying to connect with OCI methods

Warning: _oci_open_server: ORA-12154: TNS:could not resolve service name in c:\programmi\apache group\apache\htdocs\phpconnect.php on line 16
OCIDebug: _oci_open_server: FAILURE -> CLEANUP called
OCIDebug: START _oci_close_server: detaching conn=0 dbname=mezzitest
OCIDebug: _oci_close_server: closing DEAD server
OCIDebug: oci_do_connect: FAILURE -> CLEANUP called
OCIDebug: START _oci_conn_list_dtor: id=0
OCIDebug: END _oci_conn_list_dtor: id=0

--------------------------------------------------------------------------------
Trying to connect with ODBC methods

Warning: SQL error: [Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve service name , SQL state 08004 in SQLConnect in c:\programmi\apache group\apache\htdocs\phpconnect.php on line 21
Non Connesso!!! OCIDebug: START php_rshutdown_oci
OCIDebug: END php_rshutdown_oci
OCIDebug: START php_mshutdown_oci
OCIDebug: END php_mshutdown_oci

Any help would REALLY be appreciated.
Tnx, Gaetano
 
Back
Top