Connect to the OracleforNT remote database using PHP

Source: Internet
Author: User
Use PHP to connect to the OracleforNT Remote Database. read how to connect to the OracleforNT remote database using PHP. I used to connect to the remote oracle8.0.5forNT Enterprise Edition using php, but neither ODBC nor oracle interface would work. 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? Previously, I used php to connect to the remote oracle8.0.5 for NT Enterprise Edition. I cannot use ODBC or oracle interfaces. 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:
$ 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 !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.