Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    27

    Red face Unanswered: How to conecct to Oracle

    Hi,

    i try to connect php with oracle, without success 8-(
    My environment:
    Apache 1.3.36 with PHP 5.1.4 on server1: 10.0.0.1
    Oracle on server2: 10.0.0.2

    Nameresolution is ok.

    tnsnames.ora entry on server2:
    Code:
    KZT.WORLD =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = server2)(PORT = 1521))
        )
        (CONNECT_DATA =
          (SERVICE_NAME = KZT )
        )
      )
    I dont knwo how to connect php with oracle. I tried
    Code:
    $dblink= oci_connect($my_user, $my_pwd, '//server2:1521:KZT');
    but i/it faild. From my local desktop i can connect to the DB with:
    Code:
    sqlplus roli@//server2:1521/KZT
    I hope somebody can help me, yours

    Roland

  2. #2
    Join Date
    Oct 2002
    Location
    Plymouth UK
    Posts
    116
    You have two options, entering the full connection info like this:

    Code:
    $db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = server2)(PORT = 1521)))(CONNECT_DATA=(SID=KZT)))";
    
    $dblink= oci_connect($my_user, $my_pwd, $db);
    or to use the service name for your db instance and let TNS to sort the connection details for you like this:

    Code:
    $dblink= oci_connect($my_user, $my_pwd, 'KZT');
    I favour the second option because swapping servers or making any server changes only requires a change to your TNS entry and not all of you applications. You do need the oracle TNS set up on your server 1 to gain connection. The easiest way is to install and configure an Oracle client on server 1. I would guess your problem may be because of a lack of the TNS and required binaries on your server1. The php engine uses Oracle binaries which do not come as a part of the php install.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •