I have this class to connect to a database mysqlusing php/ mysqli:
class AuthDB {
private $_db;
public function __construct() {
$this->_db = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME)
or die("Problem connect to db. Error: ". mysqli_error());
}
public function __destruct() {
$this->_db->close();
unset($this->_db);
}
}
I now have a page for the list user:
require_once 'classes/AuthDB.class.php';
session_start();
$this->_db = new AuthDB();
$query = "SELECT Id, user_salt, password, is_active, is_verified FROM Users where email = ?";
$stmt = $this->_db->prepare($query);
$stmt->bind_param("s", $email);
if ($stmt->execute()) {
$stmt->bind_result($id, $salt, $pass, $active, $ver);
$stmt->fetch();
echo $id;
}
Now, I see this error:
Fatal error: Using $this when not in object context in LINE 6
How to fix this error ?!
source
share