I'm using zymichost.com trying to follow the book in the title.
This is the error I get:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user '831445_juzer'@'192.168.1.1' (using password: YES) in /www/zymichost.com/6/5/4/654456/htdocs/phpMM/connect.php on line 5
Warning: Cannot modify header information - headers already sent by (output started at /www/zymichost.com/6/5/4/654456/htdocs/phpMM/connect.php:5) in /www/zymichost.com/6/5/4/654456/htdocs/phpMM/scripts/app_config.php on line 25
This is the app_config.php file:
<?php
// Set up debug mode
define("DEBUG_MODE", true);
// Site root
define("SITE_ROOT", "/phpMM/");
// Database connection constants
define ("DATABASE_HOST", "xxxxx");
define ("DATABASE_USERNAME", "xxxxx");
define ("DATABASE_PASSWORD", "xxxxxx");
define ("DATABASE_NAME", "xxxxxx");
// function debug print
function debug_print($message) {
if (DEBUG_MODE) {
echo $message;
}
}
function handle_error($user_error_message, $system_error_message) {
header("Location: show_error.php?" . "error_message={$user_error_message}&" . "system_error_message={$system_error_message}");
exit();
}
?>
and this is the connect.php code:
<?php
require_once 'scripts/app_config.php';
if (!mysql_connect(DATABASE_HOST, DATABASE_USERNAME, "foo")) { handle_error("There was a problem connecting to the database " . "that holds the information we need to get you connected.", mysql_error());
}
echo "<p>Connected to MySQL!</p>";
if (!mysql_select_db(DATABASE_NAME)) {
handle_error("There's a configuration problem with our database.", mysql_error());
}
echo "<p>Connected to MySQL, using database " . DATABASE_NAME . ".</p>";
$result = mysql_query("SHOW TABLES;");
if (!$result) {
handle_error("There's a problem looking up information in our database.", "Error in listing tables: " . mysql_error());
}
echo "<p>Tables in database:</p>";
echo "<ul>";
while ($row = mysql_fetch_row($result)) {
echo "<li>Table: {$row[0]}</li>";
}
echo "</ul>";
?>
Initially I thought it was a whitespace issue, but I guess that's not the case.