Forum Stats

  • 3,825,949 Users
  • 2,260,582 Discussions
  • 7,896,739 Comments

Discussions

PHP with OCI8 on Windows Server 2012 R2

3227444
3227444 Member Posts: 2
edited May 3, 2016 1:07AM in PHP

Windows server 2012 r2 Standard

64 bit operating System, x64 based processor

Web server : Xampp 3.2.2

PHP : PHP Version 5.6.19

Apache Error log: PHP Warning:  PHP Startup: Unable to load dynamic library '\\xampp\\php\\ext\\php_oci8.dll' - %1 is not a valid Win32 application. in Unknown on line 0

I tried all the solutions available on google but it is not working. Initially i tried following oracle guidelines by installing 32 bit instant client libraries but it didn't work. Then I followed below link.

https://blogs.oracle.com/opal/entry/using_php_oci8_with_32-bit_php

It didn't work. Got the same error. Then tried creating symblink(Use 32 and 64bit Oracle Client in parallel on Windows 7 64-bit for e.g. .NET Apps · Realfiction) and it also didn't work. Everytime I get same error as I mentioned above. Please suggest me what am I missing here,

Answers

  • Gaz in Oz
    Gaz in Oz Member Posts: 3,785 Bronze Crown
    edited May 3, 2016 1:00AM

    Hi 3227444,

    Have you checked the output from "phpinfo()" to verify the environment is set up correctly?

    What version of Oracle Instant Client are you using?

    Have you set up your env variables under "SYSTEM" variables? (I would guess that the web server will run under SYSTEM so pick up SYSTEM variables not USER variables)

    Some of the issues others are having relate to version mismatch of the php_oci8.dll and oracle client installed...

    Cheers,

    Gaz.

  • 3227444
    3227444 Member Posts: 2
    edited Apr 29, 2016 7:08AM

    Yes checked phpinfo but OCI8 is not listed just like other modules.Please refer screen shot of phpinfo top portion.

    phpinfo-screenshot.png

    I have added path to instant client library to PATH variable. Hope you are talking about same.

    Please find additiona details.

    Xampp PHP Version :  5.6.19 Thread safe

    OCI 8 : php_oci8-2.0.11-5.6-ts-vc11-x64 (OCI 8 2.0.11 version for PHP 5.6 Thread Safe 64 bit)

    Instant Client Library : instantclient-basic-nt-11.2.0.4.0 for 32 bit. Installed in C directory.

    Oracle is not installed in our local.We are connecting to remote oracle server. Please advise if I am missing anything here.

  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,648 Employee
    edited May 2, 2016 10:57PM

    You have a mix of 32 and 64 bit binaries.  Choose one architecture and stick with it.

  • Gaz in Oz
    Gaz in Oz Member Posts: 3,785 Bronze Crown
    edited May 3, 2016 1:07AM

    Hi 3227444,

    To test a connection to an  Oracle 11.2.0.1 db running on a 64bit LINUX server I did the following:

    Downloaded xammp (32bit) for windows, xampp-win32-5.6.20-0-VC11-installer.exe and installed on a Windows server 2008 SP1 64bit machine

    Downloaded and unzipped Oracle 32bit instant client, instantclient-basiclite-nt-12.1.0.2.0.zip on the same Windows server 2008 SP1 64bit machine

    Set path to include "Y:\Oracle\instantclient12_1" as it's first entry:

    y:\> path=y:\Oracle\instantclient12_1;%path%
    
    
    
    
    
    
    
    
    
    
    
    

    Uncommented the line in xampp\php\php.ini:

    extension=php_oci8_12c.dll  ; Use with Oracle Database 12c Instant Client
    
    
    
    
    
    
    
    
    
    
    
    

    Ran xampp\php\db.php file from the command line

    <?php
    
    $db='database';
    $un='user';
    $pw='password';
    
    $conn = oci_connect($un, $pw, $db);
    if (!$conn) {
       $e = oci_error();
       trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
    }
    
    $stid = oci_parse($conn, 'SELECT TO_CHAR(SYSDATE, \'Dy DD/MM/RR HH24:MI:SS\') FROM dual');
    oci_execute($stid);
    
    while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
       foreach ($row as $item) {
          echo " " . ($item !== null ? htmlentities($item, ENT_QUOTES) : "Not found\n");
       }
       echo "\n";
    }
    
    oci_close($conn);
    
    ?>
    
    
    
    
    
    
    
    
    
    
    
    

    Y:\xammp\php> php db.php
    Tue 03/05/16 13:10:04
    
    
    
    
    
    
    
    
    
    
    
    

    and successfully connected.

    ...so set the $db, $un and $pw to a valid connection and see if you can connect from the command line.

    NOTE: both xampp, php, etc AND Oracle instant client are 32bit in this test.

    Gaz.

This discussion has been closed.