0

I am little bit confused with strange behavior of PHP and need advice how to fix it.

I am tring to test pretty simple php script:

$conn = oci_connect($dbUser, $dbPassword, $dbServerName . "/" . $dbName);
if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message']), E_USER_ERROR);
}

Unfortunatly it raise me next ERROR:

[22-Oct-2018 19:22:23] PHP Warning:  PHP Startup: Unable to load dynamic library 'F:\PHP_x64\ext\php_oci8_12c.dll' - The specified procedure could not be found.
 in Unknown on line 0
[22-Oct-2018 19:22:23] PHP Fatal error:  Call to undefined function oci_connect() in F:\TEST\complain\test.php on line 8

I have project which is located in IIS web server. Project use PHP Version 5.6.28.

enter image description here

Inside F:\PHP_x64\ext\ folder I have file php_oci8_12c.dll as you can see below: enter image description here

Inside php.ini file I have uncommented line:

extension=php_oci8_12c.dll

Also in php.ini file I add:

extension_dir = "F:\PHP_x64\ext\"
[PHP_OCI8_12C]
extension=php_oci8_12c.dll

I restart IIS web server several times.

When I try to call php.exe from console it show me next error:

enter image description here

Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193
  • Do you have any other OCI dll's enabled? – Jay Blanchard Oct 22 '18 at 13:53
  • @JayBlanchard Right now, I have only this problem. I also tried to connect to remote MySQL database by `mysqli_connect` and it works! I am not sure but for that PHP use `php_mysqli.dll` extention file, right? In my post I tried to connect to Oracle 12C database. Do you have any ideas, bro? – Nurzhan Nogerbek Oct 22 '18 at 14:08
  • That's right. Is this on a Windows server? – Jay Blanchard Oct 22 '18 at 14:11
  • @JayBlanchard yes, `IIS` web server located in `Windows Server 2008 R2`. – Nurzhan Nogerbek Oct 22 '18 at 14:13
  • On Windows, you typically can solve these kinds of problems by adding the path specified in 'extension_dir' (in php.ini) to the value of PATH system environment variable. – Jay Blanchard Oct 22 '18 at 14:14
  • I add `F:\PHP_x64\ext\` to PATH system environment variable. Restart machine but unfortunatly it did't help me. – Nurzhan Nogerbek Oct 22 '18 at 14:28
  • Possible duplicate of [Call to undefined function oci\_connect()](https://stackoverflow.com/questions/22478387/call-to-undefined-function-oci-connect) – Lex Li Oct 22 '18 at 18:44
  • Can you check my post again please? I notice one thing. When I try to call `php.exe` from console it show me error about `OCI.dll`. Do you have any ideas? – Nurzhan Nogerbek Oct 23 '18 at 03:20

1 Answers1

0

Finally I found solution which work for me.

The code which I use to connect PHP with Oracle:

$conn = oci_connect($dbUser, $dbPassword, "(DESCRIPTION=(ADDRESS_LIST =(ADDRESS=(PROTOCOL = TCP)(HOST=$dbServerName)(PORT = 1521)))(CONNECT_DATA=(SID=$dbSID)))", 'AL32UTF8') or die("Could not connect to ORACLE");

In my case I used SID, you can also use SERVICE_NAME.

Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193