mysql connect_error无法正常工作

时间:2014-02-27 13:20:11

标签: php mysqli

我有

下的数据库类
class Database {

private $db_link;
private $db_host;
private $db_user;
private $db_password;
private $database_name;

public function __construct($filename){

include ("include/".$filename);

$this->db_link = new mysqli($db_host,$db_user,$db_password);

if($this->db_link->connect_error){

throw new Exception("Database is not available. ".$this->db_link->connect_errno);
}

问题是if块没有执行,即使我把错误的细节连接到mysql数据库...请指出我是否正在解决它错误,因为我是OOP的新手

try{
$db = new Database($filename);

echo "connected";
}

catch(Exception $e){
echo "message: ".$e->getMessage();
exit();
}

0 个答案:

没有答案