我发现这个错误在我的错误日志中重复出现,我认为它导致内存泄漏导致我的网站停机。mysql_real_escape_string():拒绝用户'root'@'localhost'的访问(使用密码:否)
PHP Warning: mysql_query(): Access denied for user 'root'@'localhost' (using password: NO) in /mysql.class.php on line 74
PHP Warning: mysql_query(): A link to the server could not be established in /mysql.class.php on line 74
PHP Warning: mysql_real_escape_string(): Access denied for user 'root'@'localhost' (using password: NO) in /functions.php on line 380
PHP Warning: mysql_real_escape_string(): A link to the server could not be established in /functions.php on line 380
PHP Warning: mysql_query(): Access denied for user 'root'@'localhost' (using password: NO) in /mysql.class.php on line 100
PHP Warning: mysql_query(): A link to the server could not be established in /home/glo/mysql.class.php on line 100
在mysql.class.php,这里是从管线72中的代码,以104
function &execute() {
$query = $this->read();
**$res = mysql_query($query);** // line 74
if ($res || mysql_errno() == 1062) {
return $res;
}
$mysql_error = mysql_error();
$mysql_errno = mysql_errno();
// If debug_backtrace() is available, we can find exactly where the query was called from
if (function_exists("debug_backtrace")) {
$bt = debug_backtrace();
$i = 1;
if ($bt[$i]["function"] == "SQL_Query_exec_cached" || $bt[$i]["function"] == "get_row_count_cached" || $bt[$i]["function"] == "get_row_count")
$i++;
$line = $bt[$i]["line"];
$file = str_replace(getcwd().DIRECTORY_SEPARATOR, "", $bt[$i]["file"]);
$msg = "Database Error in $file on line $line: $mysql_error. Query was: $query.";
} else {
$file = str_replace(getcwd().DIRECTORY_SEPARATOR, "", $_SERVER["SCRIPT_FILENAME"]);
$msg = "Database Error in $file: $mysql_error. Query was: $query";
}
mysql_query("INSERT INTO `sqlerr` (`txt`, `time`)
**VALUES (".sqlesc($msg).", '".get_date_time()."')");** // line 100
if (function_exists('show_error_msg'))
show_error_msg("Database Error", "Database Error. Please report this to an Admin.", 1);
}
在的functions.php这里是代码
// MySQL escaping
function sqlesc($x) {
if (!is_numeric($x)) {
$x = "'".mysql_real_escape_string($x)."'"; // Line 380
}
return $x;
}
为我的连接的代码是
function_exists("mysql_connect") or die("MySQL support not available.");
@mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die('DATABASE: mysql_connect: ' . mysql_error());
@mysql_select_db($mysql_db) or die('DATABASE: mysql_select_db: ' . mysql_error());
任何帮助t o调试这些错误是非常感谢....
检查'$ mysql_host','$ mysql_user','$ mysql_pass'的值是否正确...... – djidi
听起来你有一个连接问题。你确定允许用户访问SQL-Server并且也是适当的表吗?而且用户真的没有密码? – Thomas
dbconnection的值都是正确的。网站正在运行,但我们说这些错误发生在某种程度上...... –