我刚来这地方。我正在开发的网站有问题。你能帮我解决一下吗。
这是完整的错误声明:
致命错误:在第 20 行的 C:\xampp\htdocs\koa\classes\class.ManageUsers.php 中调用未定义的方法 dbConnection::query()。
我以面向对象的方式使用 PHP 和 MySQL。
这是错误指向的 class.ManageUsers.php 中的代码。我将把整个函数放在这里:。
function LoginUsers($username,$password){
$query = $this->db->query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
$num_rows = $this->link->fetchRows();
return $num_rows;
}
第 20 行是:
$query = $this->db->query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
还有这里的构造函数:
function __construct(){
$this->db = new dbConnection();
$this->db->connect();
}
dbConnection 类是这样的:
class dbConnection{
protected $db_conn, $_query, $_numRows, $_fetchAll;
public $db_name = '******';
public $db_user = '******';
public $db_pass = '******';
public $db_host = '******';
function connect(){
$this->db_conn = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name, $this->db_conn);
if(mysql_errno($this->db_conn){
return mysql_error($this->db_conn);
}
else{
return $this->db_conn;
}
}
public function query($sql){
$this->_query = mysql_query($sql, $this->db_conn);
$this->_numRows = mysql_num_rows($this->_query);
$this->_fetchAll = mysql_fetch_array($this->_query);
}
}
?>