For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > April 2005 > Re: [PHP-DB] php4 can't find tnsnames.ora oracle9 but can connectif









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] php4 can't find tnsnames.ora oracle9 but can connectif
Christopher Jones

2005-04-27, 3:56 pm


Without real information I can only wonder and guess.

Is TNS_ADMIN set to a directory or a file? It should be a directory.
Try renaming sqlnet.ora temporarily or set the alias in tnsnames.ora
to something like "testdb.boo.com = (DESCRIPTION = ..."

Chris

neil smith wrote:
> Hello chris,
>
> I've modified the variables in the apache user environment (in my case
> root at the moment) but that didn't amke any difference to php not being
> able to find tnsnames.ora. So the work around I've used is to use
> ORACLE_SID="desciption(...etc..... SID = )))"; ie the full description
> of the database alias within tnsnames.ora
>
> However this is not good, so if you have any other idea please let me
> know. I'm flumuxed.
>
> thanks,
>
> neil
>
>
> >From: Christopher Jones <christopher.jones@oracle.com>
> >To: neil smith <neil989@hotmail.com>
> >CC: php-db@lists.php.net, n.a.smith@chello.nl
> >Subject: Re: [PHP-DB] php4 can't find tnsnames.ora oracle9 but can
> connectif description hardcoded
> >Date: Wed, 20 Apr 2005 09:25:12 +1000
> >
> >Make sure the environment variables are set in the shell that starts
> >Apache. See
> >http://www.oracle.com/technology/te...aq.html#envvars
>
> >
> >Try changing your OCILogon command to
> >
> > $odbc =
> OCILogon("yourusername","yourpassword",$db);
> >
> >i.e. remove "/test" from the username parameter.
> >
> >Chris
> >
> >neil smith wrote:
> >>Hello,
> >>
> >>I have test script that can connect to the oracle database. It
> >>doesn't
> >>require tnsnames.ora because I define the database alias in the
> >>script
> >>itself. It looks like this:
> >>
> >>
> >>
> >>echo
> "TWO_TASK=".getenv("TWO_TASK")."<br>";
> >>echo
> "LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH")."<br>";
>
> >>echo
> "ORACLE_BASE=".getenv("ORACLE_BASE")."<BR>";
>
> >>echo
> "ORACLE_HOME=".getenv("ORACLE_HOME")."<BR>";
>
> >>echo
> "TNS_ADMIN=".getenv("TNS_ADMIN")."<BR>";
>
> >>echo
> "NLS_LANG=".getenv("NLS_LANG").".<br>";
> >>
> >># this allows a successful connection
> >>
> >>$db = " (DESCRIPTION =
> >> (ADDRESS = (PROTOCOL = TCP) (HOST =testdb.boo.com)(PORT = 1521))
> >> (CONNECT_DATA= (SID = testdb))
> >> )";
> >>
> >>// these don't work.. php can't seem to find tnsnames.ora
> >># $db = "testdb.boo.com";
> >>//$db = "testdb.boo.com";
> >># $db = "testdb";
> >>//echo $testdb;
> >>
> >>
> >>$odbc = OCILogon("test/test","test",$db);
> >>
> >>if ($odbc == false){
> >> $msg = OCIError($odbc)."<BR>";
> >>} else {
> >>echo "success!!!<br>";
> >>}
> >>
> >>
> >>
> >>My problem is is that when I try to use the database alias in
> >>tnsnames.ora I
> >>get an ora-12154 error. I get this despite the facts that
> >>oracle_home,
> >>tns_admin and everything else is defined in the script and the
> >>tnsnames.ora
> >>contains exactly the same alias as I use in the hardcoded version
> >>(see the
> >>uncommented $db above).
> >>sqlnet.ora contains a value name_domain that apparently is appended
> >>to the
> >>alias in tnsnames.ora but accounting for this still doesn't let me
> >>connect
> >>to oracle . It's as if tnsnames.ora cannot be found. I've changed
> >>the
> >>permissions to 777 for the whole directory structure and I can
> >>successfully
> >>use tnsnames.ora with sqlplus or tnsping.
> >>
> >>Does anybody have any ideas what is going wrong? Is this a bug?
> >>
> >>thanks,
> >>
> >>neil
> >>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com