Re: [SOLVED] Re: PHP+Oracle: could not resolve service name

From: Shakespeare <>
Date: Fri, 11 Apr 2008 07:39:25 +0200
Message-ID: <47fef98e$0$14358$>

"Ana C. Dent" <> schreef in bericht news:2mBLj.30954$6J3.8137_at_newsfe13.phx...
> "Álvaro G. Vicario" <> wrote in
> news:ftlhco$fkr$
>> Álvaro G. Vicario escribió:
>>> My issue is that PHP scripts cannot connect to the database server
>>> when I run them from the *command line*. I get this error message:
>>> SQL error: [Microsoft][ODBC driver for Oracle][Oracle]ORA-12154:
>>> TNS:no
>>> se ha podido resolver el nombre del servicio, SQL state 08001 in
>>> SQLConnect
>>> Which translates into English as "could not resolve service name".
>>> The *very same code* runs fine when parsed through the web server
>>> (Apache2 + PHP module running as LocalSystem) and I've found no
>>> problems using TOAD. Apart from environment, PHP configuration is
>>> identical in command line and web.
>> Oh my... I've fixed it. I had to strip Windows line feeds out of
>> "TNSNAMES.ORA" and "SQLNET.ORA" and replace them with Unix ones!
>> GRMFFF@#$%&.......
>> BTW, is there an easy way to specify my own files for this
>> application? Now it works, I don't want it broken the day any sysadmin
>> edits the file.
> Since I don't do Windoze, this may not work for you.
> Under Unix, Oracle will look for .tnsnames.ora (note preceeding dot);
> [a.k.a a hidden file in Unix] located in users $HOME directory &
> use it if the file exists.
> Alternatively which does work for both OS is to define environmental
> variable TNS_ADMIN to point to a directory where tnsnames.ora resides.
In Windows, the TNSNAMES.ORA in de working directory (start in..) will be used first.

Shakespeare Received on Fri Apr 11 2008 - 00:39:25 CDT

Original text of this message