Database file
define("DB_HOST","localhost");
define("DB_USER","faizy");
define("DB_PASS","faizy");
define("DB_NAME","gallery_db");
?>
Database Class
<?php
class Database {
public $connection;
function __construct() {
$this->open_db_connection();
}
public function open_db_connection() {
$this->connection = mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);
if(mysqli_connect_errno) {
die ("database fails badly" . mysqli_error());
}
}
}
$database = new Database();
?>
Template
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">
Dashboard <small>Statistics Overview</small>
</h1>
<?php
if($database->connection) {
echo 'true';
}
?>
</div>
</div>
Error
Notice: Undefined variable: Notice: Trying to get property of non-object
I am using object oriented PHP and trying to give connection eror in a simple template,But is is giving another error discuss below, Can anyone suggest or resolve my problem and i have done all the includes and all