CONNECTING TO ORACLE WITH PHP
Sample PHP Code:
<?php
// Function used to output any errors and quit execution
function PrintOCIError($err)
{
echo "<pre>".$err['message']."</pre>\n";
die();
}
// Specify the proper host, port, and sid from the account details
$database = '(description=
(address=
(host=Shangri-la.lions.odu.edu)
(protocol=tcp)
(port=2121)
)
(connect_data=
(sid=ACAD)
(SERVER=DEDICATED)
)
)';
// Username from the account details
$username = "your_username";
// Password from the account details
$password = "your_password";
// Establishes the connection to Oracle
$conn = @OCILogon($username, $password, $database);
// Error checking
if (!$conn) {
$e = OCIError(); // For OCILogon errors pass no parameter
PrintOCIError($e);
}
echo "Connected OK\n";
?>