PHP- Connexion BDD- PDO
Posté : 03 sept. 2014, 15:40
Lors de la méthode de connexion, les variables ne sont pas connues. Pourtant,je les initialise dans le constructeur.
Voici le code :
Voici le code :
Code : Tout sélectionner
class MySQL{
private $_server = 'localhost';
private $_username = 'root';
private $_password = '';
private $_link = null;
private $_port = 3306;
private $_database = 'imprimantes';
//Constructeur
public function construct($_server, $_username,$_password,$_port,$_database,$_link){
$this->$_server = $server;
$this->$_username = $username;
$this->$_password = $password;
$this->$_port = $port;
$this->$_database = $database;
$this->$_link = $link;
}
public function connect (){
try {
$link = mysqli_connect($server,$username,$password,$database) or die("Error " . mysqli_error($link));
print_r($link);
}
catch (PDOException $e) {
echo 'Erreur! Track: ';
exit('Erreur : ' . $e->getMessage());
}
}
public function select (){
//$db_selected = mysqli_select_db ($this->database, $this->link);
}
}