我已将网站上传到c面板。当我尝试从浏览器访问它时,我收到以下错误:
致命错误:数据库错误0:linkID == False。连接失败。在 警告:mysql_connect():拒绝访问用户&root;' @' localhost' (使用密码:NO)in /home/anyonstr/school.anyonstrendtakesolution.co.ke/classes/Database.class.php 在第128行
致命错误:数据库错误0:linkID == False。连接失败。在 /home/anyonstr/school.anyonstrendtakesolution.co.ke/classes/Database.class.php 在第173行
然而它在xampp中工作正常。 这是我的代码,
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);
}
帮我解决问题