For whatever it's worth, here is how I resolved my Oracle TNS Connection
Everyone may have figured this out by now, but I'm a Linux/Apache/PHP newbie
and this was a major road block for me this past week.

1. Linux 6.2 (Zoot)
2. Oracle 8.1.7
3. Apache 1.3.20  (./configure --with-layout=RedHat --enable-module=so)
4. PHP 4.0.5

(./configure --apxs=/usr/sbin/apxs --with-oci8=/app/oracle/product/8.1.7 --w
ith-oracle=/app/oracle/product/8.1.7 --enable-track-vars)

When trying to connect to Oracle using ora_logon or ocilogon I would receive
an Oracle error to the tune of "TNS dropped connection SERVICE_NAME not
found," or something like that.  In fact there were several error messages
that occurred, but in essence they were all TNS errors.  I forget the exact
error message(s) and I don't wish to f-up my configuration to find out.

I tried all the voodoo that I could find in this group as well as some other
tricks found elsewhere.  All failed except for the brilliant $db =
1)))(connect_data=(service_name=xxxx)))" and then calling
$con=ocilogon("scott","tiger",$db).  That brilliant temporary fix is
provided by Pat O'Neill.

Basically what I discovered in my particular situation was that setting the
Oracle init.ora parameter db_domain = (or whatever) was the
culprit.  Once a database is created with this db_domain parameter PHP4.0.5
seems to wig out.  Everything Oracle works just great.  You can sqlplus
connect to Oracle from Linux.  You can connect to Oracle via any Windows
tool (in my case PL/SQL Developer). However when you try to connect via a
PHP script, forget-about-it, boom!  It doesn't work.

1. I commented out my db_domain parameter in
2. I deleted and rebuilt my Oracle database.
3. Use the exact name (prams=(description=address_list=...) in your
tnsnames.ora file, prams in my case, as the $db var in your PHP script
[$db="prams"; $c1=ocilogon("scott","tiger",$db)].  If you change your
tnsnames.ora name reference, for example to then change
your $db var in your PHP script accordingly.
4. Note: I do not have the user nobody added to my dba or oinstall group and
the only environment variables that I have set in my httpd startup script
are ORACLE_HOME=/app/oracle/product/8.1.7, LD_LIBRARY_PATH=$ORACLE_HOME/lib,

Viola!  For me this works.

I have no idea why this works, however.  It appears as if PHP is not really
connecting internally to Oracle in an Oracle-proper manner.  This is not to
say however that an "Oracle-proper manner" is a normal-proper manner.

Note: For those not able to rebuild their entire database with the db_domain
init.ora parameter disabled then Pat O'Neill's brilliant work-around is a
very good solution.

Robert M. Keene, OCP Certified DBA
Database Administrator/Developer

PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to