Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to a remote Oracle 11g database using PHP

I have tried to make oci_connect work, by following these directions, but I still get the error:

ora-24408 could not generate unique server group name in test.php

Here is my PHP snippet (with bogus IP):

   $tns2 = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 123.123.123.123)(PORT = 1521)) (CONNECT_DATA = (SID = foo)))";
   if ($conn = oci_connect("username","pwd", $tns2))
   {
       echo "Connected to foo";
       oci_close($conn);
   }
   else
   {
       die("could not connect to foo");
   }

I use SQL Developer and can connect to this database just fine from this Ubuntu server. I also have Java applications that connect from this Ubuntu server to the remote Oracle database without any problems.

What am I missing to make PHP work?

I even did the phpinfo() and it showed the oci8 information.

like image 829
Dean-O Avatar asked Dec 10 '25 23:12

Dean-O


1 Answers

Take a closer look to oci_connect.

And try with this conection string: "123.123.123.123:1521/foo"

$conn = oci_connect("username","pwd", "123.123.123.123:1521/foo");

Hope it helps.

like image 105
Luigi Siri Avatar answered Dec 12 '25 11:12

Luigi Siri