I used to use PHP to connect to the remote Oracle8.0.5 for NT Enterprise Edition, but neither ODBC nor the Oracle interface worked. I'm so anxious! After searching and searching, I finally found the correct way to connect. I am using the OCI interface here, but ODBC and Oracle still can't find it? What's wrong? OCI is enough!
The source code is as follows:
$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 "Connection closed successfully!";//=There is a problem here
}
}
else
{
echo "Connection failed" ;
}
?>
-----------------Explanation------------------ ------------
-----1. -PHP4 Reference Manual: (bad stuff)
OCILogon
Opens a link to Oracle.
Syntax: int OCILogon(string username, string password, string [OCACLE_SID]);
Return value: integer
Function type: Database function
Content description
This function enables PHP to establish a connection with Oracle link. The parameters username and password are the connection account and password respectively. The parameter OCACLE_SID is the database name and can be omitted. The return value is the connection code.
---2. My explanation:
I don’t need to tell you the username and password. I want to say that OCACLE_SID should be called the connection identification string, "(DESCRIPTION=(ADDRESS=(PROTOCOL =TCP)(HOST=10.65.73.3)(PORT = 1521)) (CONNECT_DATA =(SID=ORCL)) "
ADDRESS: oracle server address PROTOCOL is the transmission protocol, generally TCP; HOST: server IP address; PORT: port number, the default is it.
CONNECT_DATA: Here is The database name, or the Oracle database startup service name. You can find the specific name in "Services". As long as your Oracle is not installed, it is OCRL.
---3. What do you want to do! > (1) Confirm that your php is configured with the php_oci8.dll dynamic library.
(2) Confirm that the Oracle8i client or server is installed.
(3) Find the IP of your Oracle server and change it to. Your IP, and database name
(4) Don’t forget, you need a username and password to access the remote database
Everything is ready!