Hi Folks,

Well, thanks to a posting by Benoit Noss on 2001-01-04 I solved my problem.

Benoit's solution was to strip carriarge returns from Tnsnames.ora (remember we are 
talking Windows/DOS text files here - I would dearly love to change to a Unix box but 
our web site uses an ActiveX library that isn't available on unix).

Since we use a name server we mainly depend on Sqlnet.ora. I stripped the CR's from 
Sqlnet.ora by ftp'ing it to a unix host in ascii mode then retrieving it binary mode 
(didn't have an alternative tool at hand), re-started Apache/CGI and all was well. I 
tested with php4 as both a module and CGI and everything now works well.

You might like to strip the CR's from Tnsnames.ora as well as most Sqlnet.ora's fall 
back to Tnsnames.ora if they can't locate the service on an Oracle name server.

I tested, Oci8 connect, odbc connect and ADO. This may be of interest to Unix users 
having similar problems...many Oracle installs have two copies of Sqlnet.ora and 
Tnsnames.ora, in my case Oci8 uses the ones under ORACLE_HOME\Net80\Admin\ and odbc 
connects uses those under ORACLE_HOME\Network\Admin. This may be why stripping CR's 
from Tnsnames.ora has failed to work for some people.

On our production web server Oci AND odbc uses ORACLE_HOME\Net80\Admin\ but ADO (COM) 
uses ORACLE_HOME\Network\Admin even though the specified driver is {Oracle ODBC 
Driver} (go figure).

So a general rule of thumb on Windows servers would be to strip CR's from ALL copies 
of Sqlnet.ora and Tnsnames.ora. On unix boxes when you set the TNS_ADMIN environment 
variable before attempting an Orcale connect, ensure that it is pointing to the 
directory that actually contains Sqlnet.ora/Tnsnames.ora that your oracle client will 
be using (& make sure ORACLE_HOME is set of course).

I haven't yet figured why without stripping the CR's from the .ora files that oracle 
connects succeed when php4 is loaded as a module but fails when it is run as CGI...but 
I have noticed that some environment variables dumped using phpinfo() are different 
(such as USERPROFILE)...maybe ??? Anyway, haven't got time to delve further now, it 
can wait until I have some spare time.

Thanks to all, especially Benoit.

Paul Shortis

The following message was sent by "John Edward Molano" <[EMAIL PROTECTED]> on Wed, 9 
May 2001 15:32:54 -0500.

> Hi
> I have the even error but in oracle 7.3.3, this is:
> Warning: Oracle: Connection Failed: ORA-12154: TNS:no se ha podido resolver
> el nombre del servicio in
> C:\Inetpub\wwwroot\websuperII\pruebas\ConexionOracle.php on line 7
> Error conectando a la base de datos.
> Do you already have the solution? if yes, please send me it.
> Thanks
> John Molano
> ----- Original Message -----
> From: "Paul" <[EMAIL PROTECTED]>
> Sent: Monday, May 07, 2001 10:30 PM
> Subject: [PHP-DB] The Dreaded Oracle 8 TNS:ORA-12154 Connection Error
> > I am running PHP 4.0.4pl1 in CGI mode on Windows NT4 SP6, using Apache or
> IIS Web Server's.
> >
> > I am concentrating on Apache for this problem as it is identical
> irrespective of the Web Server.
> >
> > I'm using one of the simplest possible connection mechanisms ...
> >
> > if ($conn=Ora_Logon("user@mydatabase","pass"))
> > {
> > echo "SUCCESS ! Connected to database\n";
> > Ora_Logoff($conn);
> > }
> > else
> > {
> > echo "Failed :-( Could not connect to database\n";
> > }
> >
> > This works fine if PHP is run as an apache module but fails with the
> message
> >
> > "Warning: Oracle: Connection Failed: ORA-12154: TNS:could not resolve
> service name in c:\program files\apache group\apache\htdocs\ora.php on line
> 10"
> >
> > When Apache is re-configured to run PHP as CGI (other html on the same
> page suce as phpinfo() shows up just fine).
> >
> > At first I thought the Apache user may have been affecting privileges but
> the Apache "User" option doesn't work under Windows & I even tried running
> Apache as a service using the Administrator
> > account - no change. Have tried environment paths to ORACLE_HOME, TNS_PATH
> etc. etc. etc. all to no avail. We use sqlnet.ora with an oracle name
> server.
> >
> > I have to use CGI as PHP4 isn't to production level for use as a Filter
> with IIS & corporate policy dictates that I must prove PHP against ASP on
> the existing IIS server before I can even attempt using
> > Apache.
> >
> > I would greatly appreciate any construction :-) advise anyone can offer.
> >
> > Regards, Paul Shortis
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to