Click here to Skip to main content
15,867,568 members
Articles / General Programming
Tip/Trick

PHP with Oracle 11g on Windows 7 64-bit

Rate me:
Please Sign up or sign in to vote.
4.33/5 (4 votes)
8 Jan 2013CPOL1 min read 76.6K   5   18
It’s a very common problem for those, using Oracle 11g in Windows 7 (64-bit) with PHP applications.

Introduction

Now a day, many PHP applications have been developed keeping Oracle as database instead of MySQL and it’s a very common problem for those, using Oracle 11g in Windows 7 (64-bit) with PHP applications that the connection of Oracle database has been refused to connect. Here I have used Instant Client to connect Oracle database with my PHP application.

Instead of using separate installation of PHP and Apache, I have used here WAMP server. Just follow the step-by-step to connect Oracle database with PHP applications on the platform of Windows 7 (64-bit).

Step-by-Step

STEP 1. Install WAMP server and Oracle 11g at first.

STEP 2. For Windows 7 (64-bit), extract instantclient-basic-windows.x64-11.2.0.3.0.zip, downloaded from http://www.oracle.com/technetwork/topics/winx64soft-089540.html to C:\Windows\SysWOW64\instantclient_11_2 and set it on PATH variable for Environment variable.

Image 1

STEP 3. Reboot the system now.

STEP 4. Allow PHP extension from php.ini as

extension=php_oci8_11g.dll (just remove the ";" from the start of the line)

STEP 5. Restart WAMP server.

STEP 6. Open the file to see the database name as D:\app\Farhan\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora

 LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))


ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.168.1.2)
    )
  )

Here, the service name is found as "orcl.168.1.2" .

STEP 7. Make the connection in PHP script as oci_connect(your_username, your_password, "localhost/orcl.168.1.2");

Conclusion

Now try it on your environment, wish you will be succeeded easily to connect with Oracle database from PHP applications on the platform of Windows 7 (64-bit).

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Bangladesh Bangladesh
I have received B.Sc. degree in Computer Science and Engineering from Khulna University of Engineering and Technology, (KUET) Bangladesh in 2003 and Master of Business Administration in Management from University of Dhaka, Bangladesh in 2009. I started my IT career as a Software Engineer at BDCOM Online Limited, then worked for BRAC BDMail Network Limited (bracNet). At present, I am working with Application Development, Integration and Maintenance department of the International Centre for Diarrhoeal Disease Research, Bangladesh (ICDDR,B) - an international health research organization located in Dhaka, Bangladesh, dedicated to saving lives through research and treatment.

Comments and Discussions

 
QuestionTHANKS A LOT Pin
Stiven Marin Molina10-Oct-15 10:34
Stiven Marin Molina10-Oct-15 10:34 
Questionhow to make Make the connection in PHP script as oci_connect(your_username, your_password, "localhost/orcl.168.1.2"); Pin
Member 117426424-Jun-15 10:24
Member 117426424-Jun-15 10:24 
Questioninstalling xamp,php instant client to connect to remote oracle using sql developer Pin
Member 1110159821-Apr-15 16:08
Member 1110159821-Apr-15 16:08 
QuestionThank you to save our life Pin
Nhong Pornpot20-Apr-15 3:53
Nhong Pornpot20-Apr-15 3:53 
AnswerRe: Thank you to save our life Pin
Zamshed Farhan20-Apr-15 5:31
Zamshed Farhan20-Apr-15 5:31 
Questionphp with oracle 11g in wamp server Pin
Member 1141438930-Jan-15 0:33
Member 1141438930-Jan-15 0:33 
Questionthanks Pin
Member 963455215-Jan-13 1:51
Member 963455215-Jan-13 1:51 
AnswerRe: thanks Pin
Zamshed Farhan15-Jan-13 2:55
Zamshed Farhan15-Jan-13 2:55 
Questioncore java Pin
Member 963455212-Jan-13 23:40
Member 963455212-Jan-13 23:40 
AnswerRe: core java Pin
Zamshed Farhan14-Jan-13 23:39
Zamshed Farhan14-Jan-13 23:39 
Questionre patient form Pin
Member 963455211-Jan-13 4:33
Member 963455211-Jan-13 4:33 
AnswerRe: re patient form Pin
Zamshed Farhan11-Jan-13 4:40
Zamshed Farhan11-Jan-13 4:40 
Questionpatient form Pin
Member 963455210-Jan-13 19:36
Member 963455210-Jan-13 19:36 
AnswerRe: patient form Pin
Zamshed Farhan11-Jan-13 3:52
Zamshed Farhan11-Jan-13 3:52 
AnswerRe: patient form Pin
Zamshed Farhan11-Jan-13 3:54
Zamshed Farhan11-Jan-13 3:54 
Questionphp Pin
Member 96345529-Jan-13 20:09
Member 96345529-Jan-13 20:09 
AnswerRe: php Pin
Zamshed Farhan10-Jan-13 2:58
Zamshed Farhan10-Jan-13 2:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.