我正在使用 zymichost.com 试图按照标题中的书。
这是我得到的错误:
警告:mysql_connect() [function.mysql-connect]:/www/zymichost.com/6/5/4/654456/htdocs/ 中的用户 '831445_juzer'@'192.168.1.1'(使用密码:YES)的访问被拒绝第 5 行的 phpMM/connect.php
警告:无法修改标头信息 - 标头已由 /www/zymichost.com/6/ 中的(输出开始于 /www/zymichost.com/6/5/4/654456/htdocs/phpMM/connect.php:5)发送5/4/654456/htdocs/phpMM/scripts/app_config.php 第 25 行
这是 app_config.php 文件:
<?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();
}
?>
这是connect.php代码:
<?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>";
?>
最初我认为这是一个空白问题,但我想事实并非如此。