如题
php报错:Fatal error: Cannot call constructor in D:\xampp\htdocs\kxhb\lib\User.php on line 26直接贴上代码这是父类class Db
{
private $dbHost;            //数据库主机 private $dbUser;           //数据库用户名 private $dbPassword;      //数据库连接密码 private $dbConn;          //连接标志

private $dbResult;        //执行mysql_query()函数后产生的结

public function __construct($hostValue = 'localhost:3306',$userValue = 'root',$passwordValue)
{
$this->dbHost = $hostValue;
$this->dbUser = $userValue;
$this->dbPassword = $passwordValue;
}

public function Db_Connect()
{
$this->dbConn = mysql_connect($this->dbHost,$this->dbUser,$this->dbPassword); if (!$this->dbConn)
{
echo "数据库连接失败!";
} if (!mysql_select_db($this->dbSelect, $this->dbConn))
{
echo "数据库打开失败!";
} mysql_query("SET NAMES utf-8");
}

public function query($sqlValue)
{//SQL语句执行方法
$this->dbResult=mysql_query($sqlValue);
if(!$this->dbResult)
{
echo "error:".$sqlValue."<br>";
$sqlError = mysql_query($sqlValue) or die($this->Db_SQLError());
}
return $this->dbResult;
} //获取执行数据库基本操作的dbResult
public function Db_GetResult()
{
return $this->dbResult;
} public function Db_Insert($tableValue,$fieldValue,$insertValue)//调试通过
{//插入操作
$partstr = "INSERT INTO $tableValue";
if($fieldvalue = '')
{
$partstr .="VALUES ($insertValue)";
}
else
{
$partstr .="($fieldValue) VALUES ($insertValue)";
}
$_SESSION['partstr'] = $partstr;
return $this->query($partstr);
} public function Db_InsertId()//调试通过
{//返回新增的自增ID
return mysql_insert_id();
} public function Db_Select($tableValue, $fieldsValue = '*', $conditionValue = '')//调试通过
{//获取指定的条件的记录
if(!empty($conditionValue))
{
$partstr = "SELECT $fieldsValue FROM $tableValue WHERE $conditionValue";
}
else
{
$partstr = "SELECT $fieldsValue FROM $tableValue";
}
$this->query($partstr);
if (mysql_num_rows($this->dbResult) > 0)
{
$partRows = $this->dbResult;
return $partRows;
}
else
{
return false;
}
} public function Db_UpdateOneCol($tableValue, $conditionValue, $fieldsValue, $updateValue)//调试通过
{//更新一行
if($conditionValue =='')
{
$partstr = "UPDATE $tableValue SET $fieldsValue = $updateValue";
}
else
{
$partstr = "UPDATE $tableValue SET $fieldsValue = $updateValue WHERE $conditionValue";
}
return $this->query($partstr);
} //更新操作(参数$setValue是更新操作的值,例如"user = 'abc',name='cde'"等样子,中间要以逗号隔开),不是数字类型的字段,更新后的值要加引号
//这个用于更新多个字段数据,即多列
public function Db_UpdateSomeCols($tableValue,$conditionValue,$setValue)//调试通过
{
if ($conditionValue == "")
{
$partstr = "UPDATE $tableValue SET $setValue";
}
else
{
$partstr = "UPDATE $tableValue SET $setValue WHERE $conditionValue";
}
return $this->query($partstr);
} public  function  Db_Delete($tableValue,$conditionValue)//调试通过
{//删除操作
$partstr = "DELETE FROM $tableValue WHERE $conditionValue";
return $this->query($partstr);
}
public function Db_NumRows($sql)
{//返回结果记录数
return mysql_num_rows($this->query($sql));
}

public function Db_SQlError()
{
return mysql_error();
}

//关闭操作
public function Db_Close()
{
mysql_close($this->dbConn);
}
}
<?php
/*
 类内部的变量成员都以db开头;
 类内部的方法成员都以DB开头;(构造函数等PHP已经定义的除外)
 方法内部的局部变量都以part开头;
 方法的参数都以Value结尾;
 常量都大写;
 变量名都是开头小写,方法名都是开头大写;
 */
include 'Db.php';
class User extends Db{

/*应用操作属性*/
public $Uid;   //用户ID public $Fields; //用户其他属性 const ADMIN = 2;
//普通用户权限为0,管理员权限为2 public function __construct()
{
$this->Uid = NULL;
$this->Fields = array('username'=>'',
     'password'=>'',);
parent::__construct("localhost::3306","root","");
} public function __get($field)
{
if($field = 'userId')
return $this->Uid;
else
return $this->Fields[$field];
} /*这里请注意,由于USER除了Uid外其他的属性都在Fields中!!
 * 赋值时可以$this->username这样直接写,
 * 输出时必须$this->Fields['username']*/
public function __set($field,$value)
{
if(array_key_exists($field,$this->Fields))
{
$this->Fields[$field] = $value;
}
} /*****应用类******/
public static function getByUserName($username)//通过调试
{//由用户名获得数据
$user = new User();
$result = $user->DB_Select("`judger`","*","`name` = '".$username."'");
if($result)
{
if(mysql_num_rows($result))
{
$rs = mysql_fetch_array($result);
$user->Uid = $rs['user_id'];
$user->username = $username;
}
}
else
{
return false;
}
if($result)
{
mysql_free_result($result);
}
return $user;
} public static function getByUserId($id)
{//由id名获得数据
$user = new User();
$result = $user->DB_Select("`judger`","*","`id` = '".$id."'");
if($result)
{
$rs = mysql_fetch_array($result);
$user->Uid = $id;
$user->username = $rs['username'];
}
else
{
return false;
}
if($result)
{
mysql_free_result($result);
}
return $user;
}

public function save()//通过调试
{//如果用户ID存在,执行更新操作,反之执行插入操作,最后记录id
if($this->Uid)
{
$this->DB_UpdateSomeCols("`judger`","`user_id` = '".$this->Uid."'",
"`username` ='".$this->Fields['username']."',
`password` = '".$this->Fields['password']."'");
}
else
{
$this->DB_Insert("`kx_user`","`user_id`,`username`,`password`,`email_addr`,`student_id`,`mobile_phone`,`is_active`,`permission`,`enrolldate`",
"'','".$this->Fields['username']."',
'".$this->Fields['password']."'");
} if($this->dbResult)
{
$this->Uid = $this->DB_InsertId();
return true;
}
else
{
return false;
}
}
}
?>报错:::Fatal error: Cannot call constructor in D:\xampp\htdocs\kxhb\lib\User.php on line 26
为什么?