I have a small php class which i have edited a little to ask my question. The class is a shown beloww
class Register
{
public $notification = null;
public function __construct()
{
create_connection();
$this->validate_register();
}
public function validate_register()
{
//edit: missing double quote close
$select_register = "SELECT * FROM `student_reg`";
if($select_register_run = mysql_query($select_register))
{
$rows_returned = mysql_num_rows($select_register_run);
if($rows_returned >= 1)
{
$this->notification = 'error';
}else if($rows_returned == 0){
$this->notification = 'success';
}
}else{
$this->notification = 'error';
}
if($this->notification != null)
{
echo 'not null';
}else{ echo 'null';}
}
}
$new_register = new Register();
?>
It is clear that from the class, at any possible level, there is a value assigned to $this->notification. But for some reason, the class 'echoes' null.
The creat_connection() i built functions works perfectly but i have ommited it for the purpose of this question.
Why is this the case?
student_reg;if($select_register_run = mysql_query($select_register))Do you have error_reporting(E_ALL); on?$this->databaseConnection = create_connection();You really should use PDO or Mysqli