note 36360 added to function.ocilogon
| From: | matt at ZZZbadgernet dot freeserveZZZ dot co dot uk | Date: | Tue, 07 Oct 2003 11:10:04 +0000 |
| Subject: | note 36360 added to function.ocilogon | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-57960@lists.php.net to get a copy of this message | ||
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>";
}
--------------------------------------------------------
----
Manual Page -- http://www.php.net/manual/en/function.ocilogon.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36360
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36360&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36360&report=yes
Search -- http://master.php.net/manage/user-notes.php