How to connect php and oracle database?
oci_connect : Connect to an Oracle database.
oci_connect ( string $username , string $password [, string $connection_string [, string $character_set [, int $session_mode ]]] )
To create a connection to Oracle that can be used for the lifetime of the PHP script, perform the following steps.
<?php
// Create connection to Oracle
$conn = oci_connect(“phphol”, “welcome”, “//localhost/orcl”);
if (!$conn) {
$m = oci_error();
echo $m[‘message’], “\n”;
exit;
}else {
print “Connected to Oracle!”;
}
// Close the Oracle connection
oci_close($conn);
?>
The oci_connect() function contains the username, the password and the connection string. In this case, Oracle’s Easy Connect connection string syntax is used. It consists of the hostname and the DB service name.
The oci_close() function closes the connection. Any standard connections not explicitly closed will be automatically released when the script ends.