note 36360 deleted from function.ocilogon by tony2001
| From: | tony2001@php.net | Date: | Mon, 01 Aug 2005 22:03:16 +0000 |
| Subject: | note 36360 deleted from function.ocilogon by tony2001 | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-92910@lists.php.net to get a copy of this message | ||
Note Submitter: matt at ZZZbadgernet dot freeserveZZZ dot co dot uk
----
I've had some trouble with this for a while. I've finally sussed it.
Note that the remote connection only started working for me when I specified the complete
"GLOBAL_DBNAME" available from the listener.ora file as the SERVICE_NAME.
For a local database:
--------------------------------------------------------
putenv("ORACLE_SID=DBSID");
putenv("ORACLE_HOME=/usr/local/oracle/product/8.1.7_64");
$username = "username";
$passwd = "password";
$db="";
echo "Attemping database connection...";
$conn = @OCILogon($username,$username,$db);
if (!$conn)
{
echo "...FAILED\n";
if (OCIError($conn))
{
$erra=OCIError($conn);
dodberror("SQL Error: $erra[code] $erra[message]");
}
exit;
}
else
{
echo "...connected\n<BR>";
--------------------------------------------------------
For a remote (or local) database:
--------------------------------------------------------
putenv("ORACLE_HOME=/usr/local/oracle/product/8.1.7_64");
$username = "username";
$passwd = "password";
$db="(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)
(HOST=remotenode)(PORT=remoteport)
)
)
(CONNECT_DATA=(SERVICE_NAME=DBSID.domain))
)";
echo "Attemping database connection...";
$conn = @OCILogon($username,$username,$db);
if (!$conn)
{
echo "...FAILED\n";
if (OCIError($conn))
{
$erra=OCIError($conn);
dodberror("SQL Error: $erra[code] $erra[message]");
}
exit;
}
else
{
echo "...connected\n<BR>";
}
--------------------------------------------------------