0

I'm writing a script in php that queries an oracle database located on another server. This is my first time doing this, and I'm a little unclear about the setup. I haven't used php in years, and have sql, not oracle experience.

We have PHP 5.3.3 and oracle version 12.2 on our linux server. When I run the following php script, we get an error message:

$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = radd.wi.com)(PORT = xxxx)))(CONNECT_DATA=(SID=radd)))";
$conn = oci_connect("user", "pw", $db);

PHP Warning:  oci_connect(): ORA-12170: TNS:Connect timeout occurred in /opt/apps/dslamPoller/poll_dslam.php on line 16

I looked at the php.ini file, and I have uncommented the following lines: extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client

I looked for php_oci file on the server, but nothing turns up.

I looked at the following: oci_connect not working, I'm seeing a discrepancy between oracle version and what php.ini is looking for, but hesitate to change the oracle version to 11 when it's 12 because other scripts might rely on 12. I'm not sure if it will work to install oracle 11 on the server along side 12. I'm not sure it's a good idea to change the php version, if there's one that uses oracle 12. I was thinking of changing the oci dll file to reflect what's in 12, but don't see a similar file installed for 12.

I did find this just now... /opt/apps/transfer/oci8-2.0.12/php_oci8.h /opt/apps/transfer/oci8-2.0.12/php_oci8_int.h

I was looking at maybe I can install something.

I was looking at maybe oracle client isn't fully installed for php use.

I find it hard to believe that I would have to go through an install procedure to use oracle client on the server for php to use it. Is this the case? Do I have to do the entire install procedure for that?

I can ping the server that the oracle query is located on (radd.wi.com). It looks good.

Michele
  • 3,617
  • 12
  • 47
  • 81
  • 2
    *"I find it hard to believe that I would have to go through an install procedure to use oracle client on the server for php to use it."* - Why? Makes perfect sense to me. – GolezTrol Nov 15 '17 at 13:53
  • Can you do a TNSping from your PHP server to the Oracle db? e.g `tnsping (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=radd.wi.com)(PORT=xxxx)))(CONNECT_DATA=(SID=radd)))` – kfinity Nov 15 '17 at 14:15
  • I tried tnsping (DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = radd.wi.com)(PORT = xxxx)))(CONNECT_DATA=(SID=radd))) and it says -bash: syntax error near unexpected token `(' . I also tried it with TNSPing with caps there and it has same syntax error – Michele Nov 15 '17 at 14:28
  • We got it working using a different DB query that used mySQL instead of oracle. Thanks for the help! – Michele Nov 15 '17 at 15:53

0 Answers0