aldherl Posted March 14, 2013 Share Posted March 14, 2013 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! Quote Link to comment https://forums.phpfreaks.com/topic/275641-call-to-undefined-method-dbconnectionquery-how-to-fix-it/ Share on other sites More sharing options...
ignace Posted March 14, 2013 Share Posted March 14, 2013 The code as posted should work. Do you have dbConnection defined more then once? Quote Link to comment https://forums.phpfreaks.com/topic/275641-call-to-undefined-method-dbconnectionquery-how-to-fix-it/#findComment-1418550 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.