|
General Clean Up resets the |
Person Table |
Book Table |
Documentation |
||
|
Note - Create, Drop and Clean Up would be
hidden on a real life system. |
|||||
The PHP code below does the job.
<?php require "../MySQL_Login.php"; // Contains MySQL login details $link = mysql_connect($host, $user, $password) or die(mysql_error()); // Normally some interesting processing would take place here. mysql_close($link); ?>
Explanations:
Possible reasons for failure:
Code Listing : connect.php |
<?php
require "../MySQL_Login.php"; // Contains host, username, password, and database
$link = mysql_connect($host, $user, $password) or die(mysql_error());
// Normally some interesting processing would take place here.
mysql_close($link);
?>
<html>
<head>
<title>CONNECT TO MySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php include "nav.php"; ?>
<h2>Connect Succeeded</h2>
<p>The PHP code below does the job.</p>
<hr />
<pre><?php
require "../MySQL_Login.php"; // Contains MySQL login details
$link = mysql_connect($host, $user, $password) or die(mysql_error());
// Normally some interesting processing would take place here.
mysql_close($link);
?>
</pre>
<hr />
<p><strong>Explanations:</strong></p>
<ul>
<li><strong>MySQL_Login.php</strong> contains host, login and database details
for MySQL.</li>
<li><strong>mysql_connect</strong> makes the connection if the login credentials
are OK.</li>
<li><strong>$host, $user and $password</strong> all came from the MySQL_Login.php
file.</li>
<li><strong>or die(mysql_error())</strong> kills the script with an error message
if the connection failes for any reason.</li>
<li><strong>mysql_close</strong> closes the link. If you forget this line, the
link will eventually be closed for you.</li>
</ul>
<p><strong>Possible reasons for failure:</strong></p>
<ul>
<li>One or more of $host, $user and $password are incorrect.</li>
<li>File permissions on the server might be wrong. Execute permission is needed.</li>
<li>The web server might not be running.</li>
<li>PHP might not be set up and running.</li>
<li>MySQL might not be set up and running.</li>
</ul>
<?php
include "dump.php";
dump_page(basename($_SERVER[SCRIPT_FILENAME])); // Display the code of this page
?>
</body>
</html>
|