faqts : Computers : Programming : Languages : PHP : Database Backed Sites : Oracle : Installation

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

48 of 136 people (35%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

TNS:could not resolve service name. What's the problem?

Apr 19th, 2001 16:49
Onno Benschop, Jin-He Tsai,


This is from memory, so bear with me:

For an oracle connection to work within PHP, you need to first setup 
the oracle client. The TNS file, I know it to be called tnsnames.ora in 
my setup (this seems universal) contains a list of services that refer 
to the actual instance of the oracle database you want to connect to.

Let me say that another way.

The tnsnames.ora file contains a list of aliases to databases.

When you connect to oracle within PHP, you are actually referring to 
the service (or alias), that then points to the database.

For it all to work, you need to:

1. Define a service name in tnsnames.ora
2. Make sure you can connect with the oracle client.
3. Test the actual login from within PHP

Things to trip you up:

Generally the oracle database you are connected to is not run by you 
but the dba. The oracle dba can and will change passwords and services 
on you when they feel the need to. Make sure your software is not hard-
coded.