Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Oracle Functions [deprecated] : ora_logon

ora_logon

Open an Oracle connection (PHP 4, PHP 5 <= 5.0.5)
resource ora_logon ( string user, string password )

Establishes a connection between PHP and an Oracle database.

Connections can be made using SQL*Net by supplying the TNS name to user like this:

<?php
$conn
= Ora_Logon("user@TNSNAME", "pass");
?>

If you have character data with non-ASCII characters, you should make sure that NLS_LANG is set in your environment. For server modules, you should set it in the server's environment before starting the server.

Parameters

user

The user name.

password

The password associated with user.

Return Values

Returns a connection identifier on success, or FALSE on failure. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions.

ChangeLog

Version Description
5.1.0

The oracle extension is deprecated in favor of oci8.

Notes

When using oci8 as a replacement for the deprecated oracle extension, consider using:

oci_connect()
oci_new_connect()

Code Examples / Notes » ora_logon

knitterb

You probably want to use the more modern OCILogon and other OCI functions for logging in to a database.  Additional connection strings can also be found on the OCILogon page for documentation.

keithv

In order to get this to work properly I needed to have the ORACLE_HOME variable set before starting the Apache web server. I put it in the /etc/profile file, but you can do it anyway you choose.

devon

In addition to above comments - I had a ORA-12545 error using ora_logon that I eventually found was simply a var/path problem - when you start up "apachectl start" make sure apache can find oracle!

php developer

I also goy the ORA-1245 error using ora_logon, but setting the ORACLE_HOME var so it showed up in both the Apache Environment and Environment sections in phpinfo didn't help the situation. The full error was "Warning: Oracle: Connection Failed: ORA-12545: Connect failed because target host or object does not exist in /path/to/script on line xx." Turns out I had the oracle client installed (which is required) and I had the environment correct (which is required), but I didn't have a local tnsnames.ora file setup, so the connection couldn't find the correct binaries to connect to oracle. Creating the tnsnames.ora file on the local server (db server is remote) and using the proper syntax of "ora_logon("user@tnsentry", "password");" worked for me. Note: ORACLE_HOME and ORACLE_SID were set in the script using putenv.

premiere_fondation

Hello,
I had the problem and the solution is this one :
Use OCILogon()
Instead of writing :
$db = ("INSTANCE_NAME");
Write the entire line corresponding to your oracle instance descriptor in tnsnames.ora file :
$db = "(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = db.ip.address)(PORT = db.port)) ) (CONNECT_DATA = (SID = YOUR_DB_SID) ) )";
$con = OCILogOn("user", "password",$db);
This works perfectly.
Nicolas Corlieu.


Change Language


Follow Navioo On Twitter
ora_bind
ora_close
ora_columnname
ora_columnsize
ora_columntype
ora_commit
ora_commitoff
ora_commiton
ora_do
ora_error
ora_errorcode
ora_exec
ora_fetch_into
ora_fetch
ora_getcolumn
ora_logoff
ora_logon
ora_numcols
ora_numrows
ora_open
ora_parse
ora_plogon
ora_rollback
eXTReMe Tracker