· Installe the WampServer 2.0 (for running php )

· Installe the Oracle 10g

WampServer 2.0

WampServer 2.0


Note: There is no need to change the port address of wamp and oracle.

Then the following things to be done :

For the PHP part :

1. Search for php.ini file inside wamp(folder)

There will be two files found in the search result

(according to my Computer hardisk :

C:\wamp\bin\php\php5.2.6\php.ini
C:\wamp\bin\apache\apache2.2.8\bin\php.ini )

2. Now open the php.ini file in notepad

3. Find this :

extension=php_oci8.dll

extension=php_pdo_oci.dll

extension=php_pdo_oci8.dll

And remove the ; (semicolon ) if present before the extension word .

Before :

;extension=php_oci8.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll

After :

extension=php_oci8.dll
extension=php_pdo_oci.dll
extension=php_pdo_oci8.dll

Make the above correction in both php.ini files and save it .

For the Oracle part :

1. Run the Oracle server.

2. If the oracle server is running then , isqlplus command will run in Command prompt.

3. Go to Start -> Run -> cmd

4. And Type the following command (according to my PC)to run sqlplus:

Sqlplus scott/tiger@ORCL

sql

[Format : sqlplus username/password@service-name]

5. If stage 4 runs successfully then , type the following command in command Prompt (to run Listener):

lsnrctl

lsnrctl-1

>stop

lsnrctl-2

>start

lsnrctl-3

lsnrctl-4

6. If the stage 5 runs correctly then , type following command in command Prompt (to test connection)

[Format : tnsping service-name]

tnsping orcl

tnsping

If it successfully loaded , then the last line will show OK with some time that have taken to run the server .

Finally , create a file named oracle-php.php and test this code :

<?php
$conn = oci_connect('scott', 'tiger', '');
$sql  = oci_parse($conn, 'select * from emp');
oci_execute($sql);
while ($row = oci_fetch_assoc($sql))
echo $row['ENAME'] . "<br>";
?>

save it .

and put this file under wamp server in the wamp/www in a new folder.

1. To check that php is having connection with oci (Oracle Call Interface )

If you have the wamp welcome page , then click on phpinfo()

or

Write this code and save it with .php:

       <?php
           phpinfo();
       ?>

Inside this phpinfo() , search for “OCI8 Support”. If you get it “enabled” state , then it has got the connection with Oracle .

oci

Now run the oracle-php.php file and get the following output (according to my database ):

result

…………………….

Done.. PHP 5 and Oracle 10G connected …

I hope it has also connected for you.

You may face some problems…

This is the simple way I configured my PHP-Oracle in 2009.



No Responses Yet to “How to Connect PHP 5 with Oracle 10G in WindowsXP”  

  1. No Comments Yet

Leave a Reply