Monday, September 10 2018

How to Connect Oracle Database in PHP

In this post we have explained about how to connect oracle database in PHP using XAMPP server. You need to use oci driver for oracle connection with PHP. There are two different ways to connect PHP and Oracle.


PHP and Oracle Connection in First Method:

Enable Oracle Database 12c Instant Client in php.ini file to remove semicolon

;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client

PHP and Oracle Connection in Second Method:

Install php_oci12 extension depends on oracle version.

Once you have complete the above process and please execute the following a sample connection program to check the oracle connectivity with PHP.

Create a file connect.php

    If (!$conn)
        echo 'Failed to connect to Oracle';
        echo 'Succesfully connected with Oracle DB';

Fetch records from table

$connectTbl = oci_parse($conn, 'SELECT * FROM employees');

Thanks for reading this article. If you have any queries and please comment in the below.

Share Your Thoughts

Inline Feedbacks
View all comments
Subscribe Our Channel

Email Subscription
Watch Tutorials
Copyright © 2015 - 2021 PHPEXPERTISE.COM