PHP Windows/Oracle DB Problem

From: Date: Tue, 28 Nov 2000 17:47:38 +0000
Subject: PHP Windows/Oracle DB Problem
Groups: php.db 
Request: Send a blank email to php-db+get-4819@lists.php.net to get a copy of this message
I'm having severe problems trying to get a database connection to work under windows using PHP. I have a Windows 2000 box running Oracle 8.0.5 (DAFFY) I then have another Windows 2000 box (DEVBOX) running Inetinfo, PHP 4.. Installed on DEVBOX is the Oracle 8 Client and ODBC. This is the entry as it stands in tnsnames.ora DAFFY.WORLD = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = daffy)(PORT = 1521)) (CONNECT_DATA = (SID = ORCL)) ) Now, using the "ORACLE Net8 Easy Config" program and choosing test, then choosing the DAFFY.WORLD service, entering my username/pass and hitting text results in "The connection test was successful." So all good there. So I went into PHP and wrote the following code: <HTML><HEAD><TITLE>Hi!</TITLE></HEAD><BODY> <?php $database = OCILogon("dbman", "password", "DAFFY.WORLD"); if(!$database) die("<H1>Unable to connect!</H1>"); OCILogOff($database); echo("<H1>SUCCESS!</H1>"); ?> </BODY></HTML> This code produces the following error: Warning: _oci_open_server: ORA-12154: TNS:could not resolve service name in f:\inetpub\wwwroot\oracle.php on line 3 Unable to connect! Now I have changed the OCILogon command to use the following service variations: DAFFY, daffy, daffy.world, daffy.WORLD and DAFFY.world All result in the same exact error. I searched all my local harddrives for tnsnames.ora Installed at E:\orant\NET80\ADMIN\tnsnames.ora It is also in the SAMPLES dir and the TNSAPI dir. Just to make sure I added the daffy.world entry to both of those, no luck. In the registry it has entrys of ORACLE_HOME=E:\orant and TNS_ADMIN=E:\orant\NET80\ADMIN So thinking it was an oracle issue maybe (even though the Oracle Net8 EasyConfig test works fine) I thought I would give ODBC a try. I created a System DSN with the "Oracle ODBC Driver" version 8.00.05.00 with the datasource name mydata, service name of daffy.world and userid of dbman. I then ran the "Oracle ODBC 32Bit Test" program. Hit connect, chose the "Machine Data Source" tab, chose "mydata", filled in the password and it connected just fine with no problems. So I wrote the following PHP code: <HTML><HEAD><TITLE>Hi!</TITLE></HEAD><BODY> <?php $database = odbc_connect("mydata", "dbman", "motive"); if(!$database) die("<H1>Unable to connect!</H1>"); odbc_close($database); echo("<H1>SUCCESS!</H1>"); ?> </BODY></HTML> And then got the following error: Warning: SQL error: [Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve service name , SQL state 08004 in SQLConnect in f:\inetpub\wwwroot\odbc.php on line 3 Unable to connect! I tried changing the ODBC drive to "Microsoft ODBC for Oracle" as well as "Microsoft ODBC Driver for Oracle" Both failed in PHP (but both passed just fine in the Oracle ODBC test. I also tried making it a User DSN instead of a system DSN. Same results. Fine in the tests, fail under php. So what can I do? I've done everything I can think of. Help! Robert Schultz - robert.schultz@adelphiacom.com Knowledge Engineer - Adelphia Communications

« previous php.db (#4819) next »