当我使用此 PHP 编码时,我收到以下错误:
致命错误:无法访问第 29 行 /connection.php 中的空属性
class connectionClass
{
var $host = '';
var $user = '';
var $password = '';
var $db = '';
var $con
function __construct($flag)
{
if($flag == "local"):
$this->host = "localhost";
$this->user = "root";
elseif($flag == "remote"):
$this->host = "192.168.1.2";
$this->user = "root";
else:
echo "Incorrect connection flag.";
endif;
$this->password = $password;
$this->db = $db;
}
function connect()
{
$con = mysql_connect($this->host, $this->user, $this->password) or die(mysql_error());
mysql_select_db($this->db, $con) or die(mysql_error());
}
}
有什么建议么?提前致谢。