Whenever I'm trying to call $this->dbc
in Is_Staff
it returns an error saying:
Fatal error: Using $this when not in object context
And I'm not quite sure why it's doing this. I have tried making $dbc global but that doesn't seem to do anything.
Class BoardDatabase {
public $dbhost = "localhost"; // Host
public $dbuser = "root"; // Username
public $dbpass = ""; // Password
public $dbname = "NecBoard"; // Database
public function __construct($dbhost, $dbuser, $dbpass, $dbname) {
$this->dbc = new mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname) or die("Couldnt connect to the database! " . mysqli_errno);
if(!$this->dbc) {
die("Could not connect to database: " . $this->dbc->connect_errno());
}
}
public static function Is_Staff($type, $bool) {
if($type == "mod") {
if($bool == true) {
$IsStaff = $this->dbc->prepare("SELECT is_mod FROM users WHERE id = ?");
$IsStaff->bind_param("s", $_SESSION["id"]);
$IsStaff->execute();
$IsStaff->bind_result($is_mod);
$IsStaff->store_result();
if($IsStaff->num_rows >= 1) {
$IsStaff->fetch();
if($is_mod >= 1) {
return true;
} else {
return false;
}
}
} else {
return false;
}
}
}
}