Hello, I'm having trouble getting my view_users.php file to pull out data and display in the web browser via localhost. What is happening is (I'm getting this following error message):
The connection was reset
The connection to the server was reset while the page was loading.
* The site could be temporarily unavailable or too busy. Try again in a few
moments.
* If you are unable to load any pages, check your computer's network
connection.
* If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web.[/B]
[<?php # Script 7.6 - view_users.php
// This script retrieves all the records from the users table.
$page_title = 'View the Current Users';
include ('./header.html');
// Page header.
echo '<h1 id="mainhead">Registered Users</h1>';
require_once ('mysql_connect.php'); // Connect to the db.
// Make the query.
$query = "SELECT CONCAT(last_name, ',', first_name) AS name, DATE_FORMAT (registration_date, '%M %d, %Y') AS dr FROM users ORDER BY registration_date ASC";
$result = @mysql_query ($query); // Run the query.
$num = mysql_num_rows($result);
if ($num > 0) { // If it ran OK, display he records.
echo "<p>There are currently $num registered users.</p>\n";
// Table header.
echo '<table align="center" cellspacing="0" cellpadding="5">
<tr><td align="left"><b>Name</b></td> <td align="left"><b>Date Registered</b></td></tr>
';
// Fetch and print all the records.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<tr><td align="left">' . $row['name'] . '</td><td align="left">' . $row['dr'] . '</td></tr>
';
}
echo '</table>';
mysql_free_result ($result); // Free up the resources.
} else { // If it did not run OK.
echo '<p class="error"> There are currently no registered users.</p>';
}
mysql_close(); // Close the database connection.
include ('./footer.html'); // Include the HTML footer.
?>
That's the view_users.php code. ABOVE
<hr></hr>
Now here is the mysql_connect.php code BELOW
<?php # Script 7.2 - mysql_connect.php
// This file contains the database access information.
// This file also establishes a connection to MySQL and selects the database.
// Set the database access information as constants.
DEFINE ('DB_USER', 'username');
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'sitename');
// Make the connection.
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
// Select the database.
@mysql_select_db (DB_NAME) OR DIE ('Could not select the database: ' . mysql_error() );
?>
Please explain in simplest terms. I'm a newbie and only been coding for 1 week or two. If possible give me the code to enter and let me know where to place it. Thank you!