Jump to content

How to connect Oracle database in PHP from external network?


Go to solution Solved by Phi11W,

Recommended Posts

r/PHP

•Posted by

u/Abrar_Sh

5 minutes ago

How to connect Oracle database in PHP from external network?

Hi Friends,

I am trying to connect to oracle db from outside network.. i have enable access to that public IP and port. I am also able to ping that IP from outside network, But not able to connect to database.

Please let me know if there is any error in my code.. or is there any other way to connect.

Your help is highly appreciated.

<?php // Create connection to Oracle $conn = oci_connect("xxxxUSERNAME", "xxxxPASSWORD", "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = xx.xxx.xx.xx) (PORT = 2000) ) (CONNECT_DATA = (SID = xxxxx)))", "AL32UTF8"); if (!$conn) { $m = oci_error(); echo $m['message'], "\n"; exit; } else { print "Connected to Oracle!"; } ?>

 

Thanks for the reply Barand!

I went through that link, Still i have few confusions..

Can you be more specific please.

I am actually making an API and need to provide that ink to client so i have created a connection file as above and uploaded that in a hosting and tried to trigger that from other WWW. But the page is blank and no error msg also... How can i get that connected? Hope i was able to explain you better...Thank you once more...

Is this a right way to HOST the API?

 

 

  • Solution

If you're building an API, then it should be built and run on your own infrastructure (servers).  

If this is the case, then your Oracle database should absolutely not be exposed to the external network. 
Anything on your machine(s)?  That can be trusted.  (Mostly).  Anywhere else to your machine?  That's not trusted.  

Only the Web URL should be made available to the client and that will require you to have a Web server process (again, running on your infrastructure) that will receive those requests and process them as required. 

Do not try to use your database "like" a web server.  
Web servers have all sorts of clever "stuff" in them to protect themselves (and your Data) from the Ne'er-do-well's "out there" on the Wild, Wild Web.  
Your database does not. 

Regards, 
   Phill  W.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.