I've got this code:
<?php
class DBconnection extends Mysqli {
public $mysql;
public function __construct($host, $user, $pass, $db) {
$mysql = parent::__construct($host, $user, $pass, $db);
}
}
$mysql = new DBconnection('localhost', '**', '**', '**');
?>
But i cant make connection in a other class.
<?php
require_once('./mysqli.php');
class Activator {
private $key;
public $status;
public function __construct($key) {
$this->key = $key;
$this->status = array();
$this->activate();
}
private function activate() {
$query = $mysql->query("SELECT email, COUNT(email) AS founds FROM activation WHERE activationKey = '".$mysql->real_escape_string($this->key)."' LIMIT 1");
if($query) {
$query = $query->fetch_assoc();
if($query['founds'] == 0) {
$this->status['error'] = 'Deze code is verlopen of ongeldig.';
} else {
if($mysql->query("UPDATE users SET activation = '1' WHERE email = '".$mysql->real_escape_string($query['email'])."'")) {
$this->status['res'] = 'Uw account is geactiveerd!';
} else {
$this->status['error'] = 'Oeps, een fout! Neem contact op per email als dit over 5 minuten nog steeds zo is. Exuses voor het ongemak.';
}
}
} else {
$this->status['error'] = 'Oeps, een fout! Neem contact op per email als dit over 5 minuten nog steeds zo is. Exuses voor het ongemak.';
}
}
}
?>
How can i make it work?
This is the error:
Fatal error: Cannot redeclare class DBconnection in /home/raoul/domains/internetfaq.nl/public_html/dev/mysqli.php on line 6