I have a class I am working with:
class SlayWork
{
public function AllowDB ()
{
$MySQLi = new mysqli(DBAHost, DBAUsername, DBAPassword, DBADB);
}
}
How would I communicate with my database from another public function from within this class? example:
public function GetTest ()
{
$Var = $MySQL->prepare("SELECT * FROM test");
$Var->execute();
$Var->bind_result($ID, $Uname);
}
adding
public $MySQLi = new mysqli(DBAHost, DBAUsername, DBAPassword, DBADB);
without the public function returns:
Parse error: syntax error, unexpected 'new' (T_NEW) in C:\xampp\htdocs\Error\ClassWork.php on line 16
adding global
with the public function returns:
Parse error: syntax error, unexpected '=', expecting ',' or ';' in C:\xampp\htdocs\Error\ClassWork.php on line 18