This tutorial shows you how to use PHP with Oracle Database 11g.
First of all let’s assume that I am using windows 7 64bit along with oracle database 11G and WAMP server, so I have already downloaded Oracle instant client x64.
If you are using 32bit windows then download 32bit client otherwise it won’t work.
1. Install oracle database 11g XE
2. Install WAMP
3. Download appropriate oracle instant client
4. Extract all the content of Oracle instant client and copy all the .DLL files and paste into the directory like this D:\wamp\bin\apache\Apache2.2.17\bin
5. Turn on the WAMP server and left click on the icon > php > PHP extension > check the php_oci8_11g only, if you are using oracle database older then 11g like 10g then you must check on php_oci8 only.
6. Turn up the oracle database 11g XE services. Also the OracleServiceORCL should be there in services.
7. Write a PHP code to connect oracle with database 11g XE, and save the code in www directory of WAMP server.
Below is the sample php code to check the connection:-
$userName = "username";
$password = "paswword";
$dtabasePort = "1521";
$serverName = "localhost";
$databaseName = "ORCL";
$c = oci_connect($userName, $password, "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST $serverName)(PORT = $dtabasePort)))(CONNECT_DATA=(SID=$databaseName)))");