Abrar Posted August 12, 2021 Share Posted August 12, 2021 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!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/313538-how-to-connect-oracle-database-in-php-from-external-network/ Share on other sites More sharing options...
Barand Posted August 12, 2021 Share Posted August 12, 2021 Examples here Quote Link to comment https://forums.phpfreaks.com/topic/313538-how-to-connect-oracle-database-in-php-from-external-network/#findComment-1589045 Share on other sites More sharing options...
Abrar Posted August 15, 2021 Author Share Posted August 15, 2021 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? Quote Link to comment https://forums.phpfreaks.com/topic/313538-how-to-connect-oracle-database-in-php-from-external-network/#findComment-1589126 Share on other sites More sharing options...
Solution Phi11W Posted August 16, 2021 Solution Share Posted August 16, 2021 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. Quote Link to comment https://forums.phpfreaks.com/topic/313538-how-to-connect-oracle-database-in-php-from-external-network/#findComment-1589165 Share on other sites More sharing options...
Abrar Posted August 24, 2021 Author Share Posted August 24, 2021 Thank you so much Phill W! Exactly what i needed.. Quote Link to comment https://forums.phpfreaks.com/topic/313538-how-to-connect-oracle-database-in-php-from-external-network/#findComment-1589315 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.