我在连接到 mysql 服务器时遇到问题。我通过 Windows 的 Web 安装程序平台安装了带有 iis 7 的 PHP fast cgi。一切正常,直到我尝试连接 mysql 服务器,它总是失败。这是我的代码:
class MySqlDatabase{
private $mysql;
private $host;
private $username;
private $password;
private $db_name;
function __construct($host, $username, $password, $db_name){
$this->host = $host;
$this->username = $username;
$this->password = $password;
$this->db_name = $db_name;
}
public function connect(){
$this->mysql = mysql_connect($this->host, $this->username,
$this->password) or
die("Could not connect to database. ". $this->username .
"@" . $this->host . " passwrod: YES!");
if (!mysql_select_db($this->db_name)) die("Cannot select database!");
}
}
$database = new MySqlDataBase($host,$username,$password,$db_name);
$database->connect();