问题描述
警告:mysql_connect():对第128行/home/anyonstr/school.anyonstrendtakesolution.co.ke/classes/Database.class.php中的用户'root'@'localhost'(使用密码:NO)拒绝访问
致命错误:数据库错误0:
linkID == False。连接失败。在/home/anyonstr/school.anyonstrendtakesolution.co.ke/classes/Database.class.php第174行。
这是我的代码:
Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: NO) in /home/anyonstr/school.anyonstrendtakesolution.co.ke/classes/Database.class.php on line 128
Fatal error: Database error 0:
linkID == False. Connect failed. in /home/anyonstr/school.anyonstrendtakesolution.co.ke/classes/Database.class.php on line 174.
this is my code here:
class Database
{
# Constructor. Create an instance of this class with this.
# You would generally need just one.
private static $_singleton;
private $linkID;
private function __construct($hostname, $username, $password,
$database,
$debug=False){
$this->debug = $debug;
$this->linkID = 0;
$this->queryID = 0;
$this->queryCount = 0;
$this->errNo = 0;
$this->errStr = '';
//$this->_connection = mysql_connect();
if (! ($hostname and $username and $database))
$this->halt('Missing parameters.');
$this->linkID = mysql_connect($hostname, $username, $password);
if (! $this->linkID)
$this->halt('linkID == False. Connect failed.');
if (! mysql_select_db($database, $this->linkID))
$this->halt("Cannot use database '$database'.");
}
public static function getInstance($hostname, $username, $password,
$database, $debug=False){
if (is_null (self::$_singleton)) {
self::$_singleton = new Database($hostname, $username, $password,
$database, $debug=False);
}
return self::$_singleton;
}
/* function Database($hostname, $username, $password, $database,
$debug=False)
{
$this->debug = $debug;
$this->linkID = 0;
$this->queryID = 0;
$this->queryCount = 0;
$this->errNo = 0;
$this->errStr = '';
if (! ($hostname and $username and $database))
$this->halt('Missing parameters.');
$this->linkID = mysql_connect($hostname, $username, $password);
if (! $this->linkID)
$this->halt('linkID == False. Connect failed.');
if (! mysql_select_db($database, $this->linkID))
$this->halt("Cannot use database '$database'.");
}*/
# Halt because an error occured.
function halt($msg)
{
trigger_error(
sprintf("Database error %d: %s<br />%s\n",
$this->errNo, $this->errStr, $msg),
E_USER_ERROR);
}
第128行的代码是$ this-> linkID = mysql_connect($ hostname,$ username,$密码);第173行是E_USER_ERROR);
我尝试过:
我尝试在c面板中从我的数据库中删除用户和密码,但仍然无法正常工作。
line 128 of the code is $this->linkID = mysql_connect($hostname, $username, $password); and line 173 is E_USER_ERROR);
What I have tried:
I tried removing the user and password from my database in c panel but still doesnt work.
推荐答案
这篇关于我已将网站上传到C面板。当我尝试从浏览器访问它时,我收到以下错误:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!