I used php to connect to the remote oracle8.0.5 for NT Enterprise Edition, but neither ODBC nor oracle interfaces were available. Me too! After searching, I finally found the correct connection method. I am using the OCI interface here. I still haven't found % m between ODBC and oracle? Why 5? OCI foot already, foot already!
The source code is as follows:
<? Php
$ Dbconn = OCILogon ("zypdp", "zypdp", "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 10.65.73.3) (PORT = 1521 )) (CONNECT_DATA = (SID = ORCL )))");
If ($ dbconn! = False)
{
Echo "connection successful ";
If (OCILogOff ($ dbconn) = true)
{
Echo "the connection is closed successfully! "; // = There is a problem
}
}
Else
{
Echo "connection failed ";
}
?>
----------------- Explanation ------------------------------
----- 1. -PHP4 Reference Manual: (bad stuff)
OCILogon
Open the connection with Oracle.
Syntax: int OCILogon (string username, string password, string [OCACLE_SID]);
Return Value: integer
Function Type: database functions
Description
This function establishes a connection between PHP and Oracle. The username and password parameters are the connected accounts and passwords respectively. The OCACLE_SID parameter is the database name, which can be omitted. The return value is the connection code.
--- 2. My explanation:
User name, password does not need to be said, I want to say OCACLE_SID should be called a connection ID string, "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 10.65.73.3) (PORT = 1521 )) (CONNECT_DATA = (SID = ORCL ))"
ADDRESS: the oracle server address protocol is the transmission PROTOCOL, which generally uses TCP, HOST: Server ip address, PORT: PORT number, which is the default.
CONNECT_DATA: Here is the database name, or the Oracle database startup service name. You can find the specific name in the "service". As long as your Oracle is installed, it is OCRL.
--- 3. What are you going to do!
(1) confirm that your php has configured the php_oci8.dll dynamic library.
(2) Confirm that the Oracle8i client or server is installed.
(3) Find the ip address of your Oracle server and change it to your IP address, with the database name
(4) Don't forget to have the username and password for accessing the remote database.
Everything is ready! Do it now !!!