PHP+Oracle: could not resolve service name
PHP+Oracle: could not resolve service name
am 09.04.2008 13:35:29 von alvaro_NOSPAM
I'm developing a PHP 4 application in a Windows Server 2003 box. I'm
connecting to a remote Oracle 10g server using ODBC (with a system-wide
DSN). I didn't install any of the software and my Oracle experience doesn't
got further than writing queries ;-)
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.
After some Googling I've tried setting TNS_ADMIN and ORACLE_HOME
environmental variables but it didn't make any difference. I just can't
understand why all programs can connect except command line PHP. Do you have
any clue?
Sample code:
define('DB_DSN', 'FOO');
define('DB_USERNAME', 'FOO');
define('DB_PASSWORD', 'FOO');
odbc_connect(DB_DSN, DB_USERNAME, DB_PASSWORD);
?>
Re: PHP+Oracle: could not resolve service name
am 09.04.2008 21:34:51 von Shakespeare
"Álvaro G. Vicario" schreef in bericht
news:fti9n3$v56$1@huron.algomas.org...
> I'm developing a PHP 4 application in a Windows Server 2003 box. I'm
> connecting to a remote Oracle 10g server using ODBC (with a system-wide
> DSN). I didn't install any of the software and my Oracle experience
> doesn't got further than writing queries ;-)
>
> 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.
>
> After some Googling I've tried setting TNS_ADMIN and ORACLE_HOME
> environmental variables but it didn't make any difference. I just can't
> understand why all programs can connect except command line PHP. Do you
> have any clue?
>
> Sample code:
>
>
>
> define('DB_DSN', 'FOO');
> define('DB_USERNAME', 'FOO');
> define('DB_PASSWORD', 'FOO');
>
> odbc_connect(DB_DSN, DB_USERNAME, DB_PASSWORD);
>
> ?>
>
What did you set TNS_ADMIN to? Where is your TNSNAMES.ORA?
Shakespeare
Re: PHP+Oracle: could not resolve service name
am 09.04.2008 23:13:00 von Michael Austin
Álvaro G. Vicario wrote:
> I'm developing a PHP 4 application in a Windows Server 2003 box. I'm
> connecting to a remote Oracle 10g server using ODBC (with a system-wide
> DSN). I didn't install any of the software and my Oracle experience doesn't
> got further than writing queries ;-)
>
> 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.
>
> After some Googling I've tried setting TNS_ADMIN and ORACLE_HOME
> environmental variables but it didn't make any difference. I just can't
> understand why all programs can connect except command line PHP. Do you have
> any clue?
>
> Sample code:
>
>
>
> define('DB_DSN', 'FOO');
> define('DB_USERNAME', 'FOO');
> define('DB_PASSWORD', 'FOO');
>
> odbc_connect(DB_DSN, DB_USERNAME, DB_PASSWORD);
>
> ?>
>
>
you still need to add an entry in your tnsnames.ora file (generally
located in the oracle home under network\admin.
A google search will give you many examples of how to create a tnsnames
entry.
Re: PHP+Oracle: could not resolve service name
am 09.04.2008 23:22:54 von joel garry
On Apr 9, 4:35=A0am, "=C1lvaro G. Vicario"
wrote:
> I'm developing a PHP 4 application in a Windows Server 2003 box. I'm
> connecting to a remote Oracle 10g server using ODBC (with a system-wide
> DSN). I didn't install any of the software and my Oracle experience doesn'=
t
> got further than writing queries ;-)
>
> 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:
>
> =A0 =A0 SQL error: [Microsoft][ODBC driver for Oracle][Oracle]ORA-12154: T=
NS:no
> se ha podido resolver el nombre del servicio, SQL state 08001 in SQLConnec=
t
>
Try http://www.oracle.com/technology/pub/notes/technote_php_inst ant.html
jg
--
@home.com is bogus.
Oops! http://www.computerworld.com.au/index.php/id;314715708
Re: PHP+Oracle: could not resolve service name
am 10.04.2008 12:17:54 von alvaroNOSPAMTHANKS
Álvaro G. Vicario escribió:
> I'm developing a PHP 4 application in a Windows Server 2003 box. I'm
> connecting to a remote Oracle 10g server using ODBC (with a system-wide
> DSN). I didn't install any of the software and my Oracle experience doesn't
> got further than writing queries ;-)
>
> 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.
I've gathered some more info using Systernal's Filemon utility. It seems
that phpcli.exe does ask Windows about my TNSNAMES.ORA file; Windows
replies that the file exists. But PHP does not even try to read it. It
only reads the following file:
C:\ORANT\ISUITES\net80\admin\sqlnet.ora
AUTOMATIC_IPC = OFF
TRACE_LEVEL_CLIENT = OFF
names.directory_path = (TNSNAMES)
# names.default_domain = world
# name.default_zone = world
The only files it searches and is not found is:
C:\ORANT\ISUITES\net80\names\sdns.ora
There isn't a sdns.ora file anywhere on disk.
When I run the same script through mod_php then Apache.exe opens *and
reads* TNSNAMES.ORA :-?
[SOLVED] Re: PHP+Oracle: could not resolve service name
am 10.04.2008 19:05:27 von alvaroNOSPAMTHANKS
Á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.
Re: [SOLVED] Re: PHP+Oracle: could not resolve service name
am 11.04.2008 05:58:54 von anacedent
"Álvaro G. Vicario" wrote in
news:ftlhco$fkr$1@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
Re: [SOLVED] Re: PHP+Oracle: could not resolve service name
am 11.04.2008 07:39:25 von Shakespeare
"Ana C. Dent" schreef in bericht
news:2mBLj.30954$6J3.8137@newsfe13.phx...
> "Álvaro G. Vicario" wrote in
> news:ftlhco$fkr$1@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
In Windows, the TNSNAMES.ORA in de working directory (start in..) will be
used first.
Shakespeare
Re: [SOLVED] Re: PHP+Oracle: could not resolve service name
am 11.04.2008 09:11:15 von alvaroNOSPAMTHANKS
Shakespeare escribió:
>>> 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.
[...]
> In Windows, the TNSNAMES.ORA in de working directory (start in..) will be
> used first.
That's right. I've been playing around with current directory and
TNS_ADMIN but of course I got no results because the issue was with the
line endings.
Thank you all for your time.