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!

Connect with remote oracle database from PHP

Discussion in 'General' started by asela_05085, Sep 3, 2009.

  1. asela_05085

    asela_05085 Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    hi,

    i need to connect to a remote oracle database from a PHP script.
    Do i need to install any drivers or packages to connect with the remote database?

    when i use below code

    <?php
    if ($c = oci_connect("username", "passwd", "remote server IP")) {
    echo "Successfully connected to Oracle.";
    oci_close($c);
    } else {
    $err = oci_error();
    echo "Oracle Connect Error " . $err['text'];
    }
    ?>


    it gives below error
    "PHP Fatal error: Call to undefined function: oci_connect() "

    I'm wondering whether i need to install any drivers

    pls advice someone

    thanks
     
  2. sameer

    sameer Forum Advisor

    Messages:
    105
    Likes Received:
    6
    Trophy Points:
    240
    You need to tell php to use the oci library. In your php.ini file uncomment this line
    Restart your server if necessary. If you still can't connect you might need to add TNS_ADMIN to your PATH variable. But do the above and see first.
     
  3. asela_05085

    asela_05085 Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    i can't find that
    extension = php_oci8.dll
    in my php.ini file.
    will that be OK if i manually enter that line and restart the service?
     
  4. sameer

    sameer Forum Advisor

    Messages:
    105
    Likes Received:
    6
    Trophy Points:
    240
    Sorry what system are you on? Windows?
     
  5. asela_05085

    asela_05085 Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    it's Red Hat linux machine
     
  6. sameer

    sameer Forum Advisor

    Messages:
    105
    Likes Received:
    6
    Trophy Points:
    240
    Hi, if you are on linux, you need

    1. An Oracle client installed on your system. Oracle Instant Client will do.
    2. OCI8 Patch for PHP from Oracle

    The link http://www.akadia.com/services/ora_php_linux.html gives a good idea on what you have to do. It's based on Gentoo but you will get the drift.
     
  7. sameer

    sameer Forum Advisor

    Messages:
    105
    Likes Received:
    6
    Trophy Points:
    240