Bonsoir,
En voulant me connecter à ma base de donnée en PDO et POO, je rencontre une erreur.
Fichier : database.class.php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part Fatal error: Cannot redeclare class database in C:\xampp\htdocs\Forum\config\database.class.php on line 3
Fichier index.php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 <?php class database { protected $_host; protected $_dbname; protected $_username; protected $_password; public function __construct($_host, $_dbname, $_username, $_password) { $this->_host = $_host; $this->_dbname = $_dbname; $this->_username = $_username; $this->_password = $_password; } public function PDOConnexion() { $bdd = new PDO('mysql:host='.$this->_host.'; dbname='.$this->_dbname, $this->_username, $this->_password); $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } } ?>
Un grand merci à ceux qui m'aideront !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <?php require_once('config/database.class.php'); $connexion = new Database('localhost', 'Blablabla', 'root', ''); $connexion->PDOConnexion(); ?>
Partager