我已将网站上传到C面板。当我尝试从浏览器访问它时,我收到以下错误: [英] I have uploaded a website to C panel. When I try to access it from my browser I get the following error:

查看:66
本文介绍了我已将网站上传到C面板。当我尝试从浏览器访问它时,我收到以下错误:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

警告: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.

推荐答案

_singleton ;
private
_singleton; private


linkID ;
私函数__construct(
linkID; private function __construct(


hostname,


这篇关于我已将网站上传到C面板。当我尝试从浏览器访问它时,我收到以下错误:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆