Jump to content

Call to undefined method dbConnection::query() - How to fix it?


aldherl

Recommended Posts

Hi guys!

I am new here. I am having problems with my site that I am developing. Could you help me how to fix it.

This is the complete error statement, Fatal error: Call to undefined method dbConnection::query() inC:\xampp\htdocs\koa\classes\class.ManageUsers.php on line 20.
I am using PHP, and MySQL in an Object Oriented way.

Here is the code in the class.ManageUsers.php that the error is pointing to. I will put the whole function here:

 

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;
		}

 

The line 20 is:

 

$query = $this->db->query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");

 

Also the construct function here:

function __construct(){
	$this->db = new dbConnection();
	$this->db->connect();
}

 

The dbConnection class is this:

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);
		}
}
?>

 

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.