Connect Amazon RDS Oracle DB AWS Through PHP

I had troubles at start on how exactly to connect to Amazon RDS Oracle DB AWS through my php code, but finally found the solution and it works perfect.

Its a bit hard in sequence on which variable to put here, so I thought it will be easier to identify how I got it connected and in working format.

Connect Oracle AWS With PHP

Here is the code which lets you connect to your oracle db in AWS:


$host = "//xxxxx.amazonaws.com";
$port = "xxxx";
$sid = "xxx";
$connection_string = $host.":".$port."/".$sid;

$db_user = "xxxx";
$db_password = "xxxx";

if(!@($conn = oci_connect($db_user, $db_password, $connection_string)))
{
	print_r(ocierror());
}

$sql = "....";

Hope the above sample code works for you and let you connect to your oracle db aws without any more problems.

Leave a Reply

Your email address will not be published. Required fields are marked *