Search code examples
phpdatabaseoracle-databaseoracle-xe

Connect from php to oracle database in windows x64


I am trying to connect from php to oracle database in windows x64

I use: php5, apache2, oraclexe 10.2

My file "test.php" is the following:

 <?php
  if ($c = oci_connect("SYSTEM", "root", "//localhost:1521/XE")) {
   echo "Successfully connected to Oracle.";
   oci_close($c);
  } else {
   $err = oci_error();
   echo "Oracle Connect Error " . $err['text'];
  }
 ?>

When I open localhost/test.php, getting a following error:

Warning: oci_connect() [function.oci-connect]: ORA-06413: Connection not open

I can not understand the cause of this error, because I have already connected to the same database from Java, and I think the php.ini file is well configured, because I managed to connect from php to MySQL database. Also followed this tutorial: http://www.orafaq.com/wiki/PHP_FAQ

So if someone have a solutions and comments post it please


Solution

  • Is XE the service name of your database? That's the name used in the example code that you have to change.