Home >Backend Development >PHP Tutorial >Use PHP to connect to Oracle for NT remote database_PHP tutorial

Use PHP to connect to Oracle for NT remote database_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:05:24827browse

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!

http://www.bkjia.com/PHPjc/315677.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315677.htmlTechArticleI 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 much searching, I finally found the correct way to connect. I use the OCI interface here...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn