Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Oracle (https://www.askmehelpdesk.com/forumdisplay.php?f=443)
-   -   Connect with remote oracle database from PHP (https://www.askmehelpdesk.com/showthread.php?t=393082)

  • Sep 3, 2009, 05:51 AM
    asela_05085
    Connect with remote oracle database from PHP
    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

    Advice someone

    Thanks
    Edit/Delete Message
  • Sep 3, 2009, 06:22 AM
    retsoksirhc

    What type of server are you using? You need to enable support for oracle in php, either by compiling it with support or installing relevant packages on linux, or uncommenting the line to include the extension dll in windows.
  • Sep 3, 2009, 06:24 AM
    retsoksirhc
    This link may help, too
    PHP: OCI8 - Manual

    I'm not really familiar with Oracle, but I do know my way around PHP pretty well.
  • Sep 3, 2009, 06:30 AM
    asela_05085
    I'm running my WEB Service on redhat linux machine with PHP 4.3 and I need to connect with a remote oracle db.
    Can you let me know what are those packages.
    I have searhed but couldn't found anything

    Thanks
  • Sep 3, 2009, 07:09 AM
    retsoksirhc

    I'd start with this to install the oracle libraries on your linux box. It'd probably be easiest to just download and run the RPM
    Instant Client downloads for Linux x86

    Then I would find your PHP ./configure (where you had installed PHP from) and run it again, with --with-oci8, along with all your other options. One of the examples here: PHP: Installation - Manual says to do this

    /configure --with-oci8=instantclient,/usr/lib/oracle/10.2.0.2/client

    There should be one option on that pages that works for you.
  • Sep 3, 2009, 08:13 PM
    asela_05085

    Thanks retsoksirhc.
    I'll try that

  • All times are GMT -7. The time now is 09:15 AM.