<html>
<! OracleStandardConnection.php                               >
<! Chapter 13, Oracle Database XE PHP Web Programming         >
<! by Michael McLaughlin                                      >
<!                                                            >
<! The script program test a standard connection to an Oracle >
<! database. You should run create_signon_triggers.sql prior  >
<! to running this program. The login and logout script       >
<! triggers capture connections by building a table, a        >
<! package with two procedures, and two database triggers.    >
<head>
<title>
  Chapter 13: OracleStandardConnection.php
</title>
</head>
<body>
<?php
  // Attempt to connect with user schema and password, then TNS alias.
  if ($c = @oci_connect("php","php","xe"))
  {
    // Print successful message to web page.
    echo "Successfully connected to Oracle.<br />";

    // Disconnect from the database.
    oci_close($c);
  }
  else
  {
    // Assign the OCI error and format double and single quotes.
    $errorMessage = oci_error();

    // Open HTML table.
    print '<table border="1" cellpadding="0" cellspacing="0">';

    // Write array elements.
    foreach ($errorMessage as $name => $value)
      print '<tr><td>'.$name.'</td><td>'.$value.'</td></tr>';

    // Close HTML table.
    print '</table>';
  }
?>
</body>
</html>
