Ben Mabrouk Mohamed Ben Mabrouk Mohamed - 6 months ago 13
PHP Question

Connecting to Oracle Database 11g using PHP code

I am trying to develop a web application with php that will connect to an 11g oracle database.

Here is my code:

//database parameter
$db_name = "my_base";
$user = "username";
$password = "password";
$sid = "sid_number";
$port = "1521";

//function of connection
$conn = oci_connect ($user, $password, "//localhost/".$db_name);


Is the connection line correct? Also I'm not introducing the port number and
sid
. Can someone tell me if the port number and
sid
are required or not?

Answer

Your connection string is correct it's not required port number & service number but if aren't able to connect & you changed the default setting you can always add port number & service in your connection string like this [//]host_name[:port][/service_name][:server_type][/instance_name] read more from here http://php.net/manual/en/function.oci-connect.php#refsect1-function.oci-connect-parameters