Notice: Undefined variable: mysqli_connection in /h2/home/suvenirc/public_html/system/database/mysql.php on line 10
Warning: mysqli_select_db() expects parameter 1 to be mysqli, null given in /h2/home/suvenirc/public_html/system/database/mysql.php on line 10
Код:
<?php
final class MySQL {
private $connection;
public function __construct($hostname, $username, $password, $database) {
if (!$this->connection = mysqli_connect($hostname, $username, $password)) {
exit('Error: Could not make a database connection using ' . $username . '@' . $hostname);
}
if (!mysqli_select_db($mysqli_connection, '$database')) {
exit('Error: Could not connect to database ' . $database);
}
mysqli_query($this->connection, "SET NAMES 'utf8'");
mysqli_query($this->connection, "SET CHARACTER SET utf8");
mysqli_query($this->connection, "SET CHARACTER_SET_CONNECTION=utf8");
mysqli_query($this->connection, "SET SQL_MODE = ''");
}