- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi, im not too good with this, i don’t really understand the error message that im getting.
This is the code.
class DBConnection
{
private $_hostName;
private $_userName;
private $_userPassowrd;
private $_dbName;
private $_dbConnection;
private $_dbQuery;
public function __construct($hostName, $userName, $userPassword, $dbName)
{
$this->_hostName = $hostName;
$this->_userName = $userName;
$this->_userPassword = $userPassword;
$this->_dbName = $dbName;
}
public function connectToDB()
{
$this->_dbConnection = new mysqli($this->_hostName, $this->_userName, $this->_userPassword, $this->_dbName) or die();
return ($this->_dbConnection) ? true : false;
}
public function logInUser($userMail, $userPassword)
{
$tempResult = $this->_dbConnection->query("SELECT * FROM userDetails WHERE userMail='$userMail' AND userPassword='$userPassword'");
if ($tempResult)
return $tempResult->fetch_assoc();
else
return false;
}
}
This is the error.
Fatal error: Call to a member function query() on a non-object in / “directory”/scripts/php/class/DBConnection.php on line 30
Make sure there is a connection before you call ‘query’. It looks like you’re calling logInUser while _dbConnection has no value yet.