<!DOCTYPE html> <html> <head>
<?php include 'css.htm';?> <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/> <meta http-equiv="Pragma" content="no-cache"/> <meta http-equiv="Expires" content="0"/>
</head>
<body>
<?php
$pageName = basename($_SERVER['PHP_SELF']); /* Returns The Current PHP File Name */ echo "<h3> " . $pageName . "</h3> "; echo " <a href='../my-php/read_code.php?file=" . $pageName . "' target='_blank'> View Code </a>"; ?>
<table background="images/bg.png" style="width:98%" style="height:640px">
<tr> <td width=20% style="vertical-align:top"> <br> <?php include 'menu.php'; ?> </td> <td height="95%" bgcolor="white" style="vertical-align:top"> <h2>Databe Connections</h2><br> <?php echo("attempting to connect to the database<br> <br> "); // connect to database $servername = "localhost"; $username = "u346389993_jamied4"; $password = "TestDataBase1"; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully!<br><br> "; echo "<br>attempting to close connection...<br><br> ";
// Check closed connection if($conn) { mysqli_close($conn); echo "Connection closed"; }
?>
<br><br> Here is the php code I used to open and close a database connection. Note a database was previously created and uploaded to the server.<br><br> <img src="images/php_connection.jpg" alt="php open and close database connection."><br><br> </td> </tr> </table> </body> </html>
|