Home >Backend Development >PHP Tutorial >A brief discussion on the connection settings between PHP4.0 and oracle 8 under Windows_PHP Tutorial
It is very easy for PHP to connect to oracle8 under Linux/Unix, but it is really not easy under the windows platform. I have found a reliable method after a long period of exploration, and I dare not keep it to myself.
I will publish it now for everyone.
The development environment I use:
windows 98 second edition
php4.04pl1
apache 1.3.14 window version
oracle 8.05 client
After PHP is installed in CGI mode and tested successfully. Test with the following code
$conn = OCILogon("cinmsiii","cinmsiii","(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.202)(PORT = 1521 ))(CONNECT_DATA = (SID = unicom)))");
//$conn=OCILogon("cinmsiii","cinmsiii","cinms"); If the oracle client is 8.1.6i, you can use it like this , the parameters are as shown above
if($conn!=false)
{
echo "ok";
OCILogoff($conn);
}
else
echo "false";
?> ;
Regarding the connection parameter issue:
The connection string is set to the following:
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.202)(PORT = 1521))(CONNECT_DATA = (SID = unicom)) )
PROTOCOL: the network protocol used
HOST: is the host name of the database server
SID: is the instance number of the database
There are usually no problems after doing this.
If your Oracle 8 client is 8.1.6i Enterprise Edition, you can set these parameters in the connection string and use Oracle8's net easy config utility to set them.
Pass in the set connection string name as the connection string.
It is speculated that Oracle 7.x can also use this method. Since there is no environment, it has not been tested. If you are interested, you can try it. (Source: Viphot)