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

From: Ana C. Dent <anacedent_at_hotmail.com>
Date: Fri, 11 Apr 2008 03:58:54 GMT
Message-ID: <2mBLj.30954$6J3.8137@newsfe13.phx>


"Álvaro G. Vicario" <alvaroNOSPAMTHANKS_at_demogracia.com> wrote in news:ftlhco$fkr$1_at_huron.algomas.org:

> Á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!
>
> http://www.phpbuilder.com/lists/php-db/2001051/0192.php
>
> 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.

HTH & YMMV Received on Thu Apr 10 2008 - 22:58:54 CDT

Original text of this message