mysql_select_db返回false

时间:2014-02-06 05:18:41

标签: php mysql

有一个有效的网站,但今天我收到了这个错误:

Access denied for user 'userName'@'' to database 'databaseName'

它不显示主机名。为什么呢?

我确信mysql_pconnect正常工作,但mysql_select_db没有。

function connect() {
    $this->connectionID=mysql_pconnect($this->server.(!empty($this->post) ? ":".$this->post : ""), $this->username, $this->password);
    if ($this->connectionID === false) {
        exit("Core module error: mysql error: ".mysql_error($this->connectionID));
    }

    if (mysql_set_charset("utf8", $this->connectionID) !== true) {
        // Windows bug detected: can't initaliaze charset cp1251, try to force setup
        $this->query("SET NAMES 'utf8'", $this->connectionID);
        $this->query("SET CHARACTER SET 'utf8'", $this->connectionID);
        $this->query("SET @@collation_connection = utf8_general_ci", $this->connectionID);
    }

    if (mysql_select_db($this->db, $this->connectionID) === false) {
//error is here
        exit("Core module error: mysql error: ".mysql_error($this->connectionID));
    }

    return true;
}

0 个答案:

没有答案
相关问题