1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Issues connecting to Oracle 8 via PHP using IIS

Discussion in 'Installation - Windows' started by Steve.Smith, Dec 18, 2013.

  1. Steve.Smith

    Steve.Smith Active Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    55
    I am attempting to connect to an Oracle 8 server running on our LAN, from a Windows server using IIS.

    PHP is installed and working on the server.

    I have downloaded the Instant Client and placed that directory within the PHP directory.

    I have added the Instant Client path to the Windows SYSTEM environment variables PATH.

    I have enabled the extension in PHP.

    Code (Text):
    extension=php_oci8.dll
    is present in php.ini.

    Created a index.php with the contents:

    Code (Text):
    <?php

    $conn = oci_connect('user', 'password', 'hostname/L');

    if ($conn) {
        echo "Connected to Oracle.";
        oci_close($conn);
    }

    if (!$conn) {
        echo "Not connected to Oracle.";
    }

    ?>
     
    I get a HTTP 500 Internal Server Error and an error message logged in php54_errors.log:

    Code (Text):
    [18-Dec-2013 08:41:33 Europe/Dublin] PHP Fatal error:  Call to undefined function oci_connect() in index.php on line 3
    When I remove the oci_connect and have some simple PHP like
    Code (Text):
    echo "Test";
    this works ok.

    Does someone have some suggestion on what is wrong here please?
     
  2. DTSIGuy

    DTSIGuy Forum Advisor

    Messages:
    402
    Likes Received:
    58
    Trophy Points:
    410
    Location:
    Texas
    Which instance of the Instant Client did you download?
     
  3. Steve.Smith

    Steve.Smith Active Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    55
    I have used instantclient10_1.
     
  4. DTSIGuy

    DTSIGuy Forum Advisor

    Messages:
    402
    Likes Received:
    58
    Trophy Points:
    410
    Location:
    Texas
    You might have to go older...you would have better luck if you could find a 9 client.
     
  5. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,345
    Likes Received:
    347
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    To get an older (9i or earlier) client you will need to have access to MOS and submit an SR, presuming you don't know anyone with the 9i or earlier client software distribution who will share it with you.
     
  6. Steve.Smith

    Steve.Smith Active Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    55
    I have been told that there is no Instant Client of that version.

    I was also told that the Instant Client 10 works ok with this version of Oracle 8 just not previous versions.

    Wouldn't it throw some error message if I was using an unsupported version like usual?

    So it makes me think that the setup is not complete which is why I posted what I've done so far here in case someone here spots something that has been missed.
     
  7. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,345
    Likes Received:
    347
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Verify your path is set correctly to include the Instant Client location.
     
  8. Steve.Smith

    Steve.Smith Active Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    55
    In %PATH% there is
    Code (Text):
    C:\Program Files (x86)\PHP\v5.3\instantclient_10_1
    .

    This is the correct path of where the downloaded Instant Client has been placed.
     
  9. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,345
    Likes Received:
    347
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    It may be the () in the path that are causing you grief -- I know that TOAD and a few other tools can't find a tnsnames.ora file for the same reason. You can download junction.exe ( http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx ) and create a 'symbolic' link to that installation into a directory not named with (), then change the PATH string to point to this linked location to see if that's the problem.
     
  10. Steve.Smith

    Steve.Smith Active Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    55
    Should I have this tnsnames.ora somewhere then? As I don't.
     
  11. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,345
    Likes Received:
    347
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    My comment was directed at the pathing, not the tnsnames.ora file specifically. It may be that the () in the path aren't interpreted correctly by PHP or apache causing the error you see regarding oci_connect (meaning the php library you have listed can't be 'found'). Try downloading junction.exe and follow the instructions on creating a 'junction' (a symbolic link in Windows) to the current Oracle client installation in a directory not named with (). Change the PATH string to reference this new location and see if that fixes things. If you no longer get the error that oci_connect can't be found you've fixed that problem. If you still can't connect for Oracle-related reasons then we'll discuss the tnsnames.ora file.
     
  12. Steve.Smith

    Steve.Smith Active Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    55
    Moved the directory to C:\instantclient, updated PATH and restarted the server (complete restart).

    I see an error in the PHP log now that I haven't seen previously. Previously it was regarding oci_connect etc. but now there's an additional:

    [18-Dec-2013 19:29:33 Europe/Dublin] PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\PHP\v5.3\ext\php_oci8.dll' - The specified module could not be found.
    in Unknown on line 0

    C:\Program Files (x86)\PHP\v5.3\ext\php_oci8.dll is present?
     
  13. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,345
    Likes Received:
    347
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    junction won't remove it, it makes a 'copy' (if you will) in the new location. You may also need to update the php.ini file to reference this new symbolic location.
     
  14. Steve.Smith

    Steve.Smith Active Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    55
    No, I'm just saying that instead of creating a symlink, I just moved the Instant Client to a more logical place (and easier).