<?php
require_once('database.php');
new Database();
class Menu
{
public $query = 'SELECT * FROM menu';
function __construct()
{
$result = mysqli_query($link, $this->query);
$menu = mysqli_fetch_array($res);
printr($menu);
}
}
new Menu();
?>
<?php
class Database
{
public $host = "localhost";
public $user = "chilion_oo";
public $pass = "*****";
public $base = "chilion_oo";
public $link = false;
function __construct()
{
$link = mysqli_connect($this->host, $this->user, $this->pass, $this->base);
if(!$link){
die('Could not connect to the database. Error:'.mysqli_error($link));
}
else {
print 'Succesfully connected to the database';
}
}
function disconnect()
{
mysql_close($link);
}
}
?>
Succesfully connected to the database
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/chilion/domains/chilion.nl/public_html/marc/inc/menu.php on line 14
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/chilion/domains/chilion.nl/public_html/marc/inc/menu.php on line 15
Fatal error: Call to undefined function printr() in /home/chilion/domains/chilion.nl/public_html/marc/inc/menu.php on line 17
<?php
require_once('database.php');
class Menu
{
public $query = 'SELECT * FROM menu';
private $_db;
function __construct()
{
$_db = new Database();
$result = mysqli_query($_db->link, $this->query);
$menu = mysqli_fetch_array($result);
print_r($menu);
}
}
new Menu();
?>
Succesfully connected to the database
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/chilion/domains/chilion.nl/public_html/marc/inc/menu.php on line 14
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/chilion/domains/chilion.nl/public_html/marc/inc/menu.php on line 15
Succesfully connected to the database
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/chilion/domains/chilion.nl/public_html/marc/inc/menu.php on line 14
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result,null given in /home/chilion/domains/chilion.nl/public_html/marc/inc/menu.php on line 15