search for in the  
<ociparseociresult>
Last updated: Thu, 19 May 2005

ociplogon

(PHP 3 >= 3.0.8, PHP 4, PHP 5)

ociplogon --  Connect to an Oracle database using a persistent connection

Description

resource ociplogon ( string username, string password [, string db [, string charset]] )

ociplogon() creates a persistent connection to an Oracle 8 database and logs on. The optional third parameter can either contain the name of the local Oracle instance or the name of the entry in tnsnames.ora to which you want to connect. If the optional third parameter is not specified, PHP uses the environment variables ORACLE_SID (Oracle instance) or TWO_TASK (tnsnames.ora) to determine which database to connect to.

Using Oracle server version 9.2 and greater, you can indicate charset parameter, which will be used in the new connection. If you're using Oracle server < 9.2, this parameter will be ignored and NLS_LANG environment variable will be used instead.

Note: This function was renamed to oci_pconnect() after PHP >= 5.0.0. For downward compatibility ociplogon() can also be used. This is deprecated, however.



User Contributed Notes
ociplogon
M0no at ethonfusino dot com
21-Nov-2002 12:04
If your oracle database is on a remote system within your local network and you don't want to worry about the tnsnames file you can try this.

$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.XX.XXX)(PORT = 1521)))(CONNECT_DATA=(SID=XXXX)))";

$c1 = ocilogon("name","password",$db);

Hope this helps someone.
kakukkfu at mailbox dot hu
26-Sep-2002 01:09
Better to insert needed variables into apache(!) (or your webserver - respectively) start script.

For example on UNIX systems /etc/init.d/apache would contain following lines before anything else:

#!/bin/bash

if [ -f ~oracle/.profile ]; then
       source ~oracle/.profile
fi

The ~oracle/.profile has the appropiate settings to start an Oracle database so it is always up-to-date for PHP, too. (If settings are changed, don't forget to restart your webserver.) This way you just no need to worry what to include or define for PHP.
e dot v dot wijk at hetnet dot nl
06-Apr-2001 09:26
The solution for not being able to connect to an Oracle database usually is setting the right system variables (ORACLE_HOME, etc...). However, it often happens that you are still not able to connect, even though these settings are correctly set.

If this is the case, try the following:

Instead of refering to the entry in the tnsnames.ora, use the actual string from the tnsnames.ora:

$User = "john"
$Password = "doe"
$Database = "(DESCRIPTION = ADDRESS_LIST (ADDRESS = (PROTOCOL= TCP (Host= yourhost) (Port= 1526)))(CONNECT_DATA = (SID = YourTnsSID )))";

OCIPLogon($User, $Password, $Database)

I hope this is helpfull for those strugling to connect to an Oracle database.

Edwin van Wijk
steve at stevedix dot de
07-Feb-2001 09:17
IF you're wondering exactly what you are dealing with, here's a brief explanation:  Oracle is NOT like mysql, which makes it very easy to connect between databases.  Oracle uses a product called sql*net to control connection between remote machines, clients and databases.  It is capable of operating on multiple different network protocols, and requires listeners to be configured for the network protocol you plan to use (usually tcp). This system has its own domain name system which rationalises database names with machines (which is why you don't have a host variable in the OCIPlogin). Configuring these listeners is not easy and requires the editing of two files tnsnames.ora and sqlnet.ora.  Even more important is to make sure that the oracle environment variable TNS_ADMIN points to the place where you put tnsnames.ora and sqlnet.ora

A good place to start reading about this is

http://www.atr.net/faq/software/FRONT_END/faqnet.htm

A more detailed version can be found at :

http://www.orafaq.net/faqnet.htm

Bear in mind that this is an incredibly complex product and not something that you should really be playing with if you don't know what you're doing.  I've seen (otherwise) experienced oracle admins baulk at configuring sql*net.  Pat solutions (like the one above) cannot be used verbatim - you will need to know and substitute several symbolic names.

HTH
mnamdeo at yahoo dot com
14-Aug-2000 04:48
<b>Connect to multiple oracle databases</b>
<p>Easy solution<br>
If you are using phplib, change local.inc $this->$database = <REMOTE_DATABASE_IN_TNSNAMES.ORA>;
<p>That's it.
michel at diefirma dot de
02-Aug-2000 02:03
After hours of weird searching and "try an error"-games with oracle and php I´ve got my working system with connection to a remote oracle server. Yeah! Documentation is very bad for this topic and the posts in all the mailing lists are very confusing. But now...

cheers. it works!

here my working sample code (php4 on debian, oracle 8.1.5.0.2 client, oracle 8i enterprise server on win2k)

michel

<pre>
$user = "scott";
$pass = "tiger";
$tns_name = "my_service_name_in_tnsnames.ora";

// set ORACLE Dir to get the NET8 name resolver working
// tnsnames.ora has to be in $ORACLE_HOME/networking/admin/
putenv("ORACLE_HOME=/home/oracle01/app/oracle/product/8.1.5");

// log on to oracle server using data above
$db_id = OCILogon ($user, $pass, $tns_name);
</pre>

<ociparseociresult>
 Last updated: Thu, 19 May 2005
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: The Server Pages
Last updated: Thu May 19 17:35:34 2005 CDT