Trouble with connecting to an Oracle database with PHP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Trouble with connecting to an Oracle database with PHP

Postby gskluzacek » 08. July 2009 19:59

I was getting the following error when trying to use php to connect to an oracle database

oci_connect() [function.oci-connect]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries

Here's how I fixed it....

I had just installed XAMPP on Win XP and wanted to use PHP to connect to an Oracle database. I had not previously installed XAMPP or anything Oracle on the computer - here's how I got OCI8 working...

I downloaded and ran the XAMPP installer & installed to the C:\xampp directory ... taller.exe

I edited the c:\xampp\php\php.ini and uncommented the following line (by taking out the ';' at the beginning of the line)


next I downloaded the Oracle 10 instant client (user login required) ...

unzipped and copied the files into the C:\xampp\apache\bin directory

Finally I restarted Apache... I can now connect to an oracle db using the following:

Code: Select all
$uid = '<uid>';
$pw = '<pw>';
$conn = '//<host>:<port>/<sid>';

$ora_dbh = oci_connect($uid, $pw, $conn);
if (!$ora_dbh) {
   $e = oci_error();
   die ("Could not connect to Oracle " . $e['message']);

Here's example connection string


hopes this helps someone as it took me much searching and lots of trial and error.

Greg Skluzacek
Posts: 1
Joined: 08. July 2009 19:19

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 27 guests