Bonsoir,

je débute en POO ; j'ai fait une connexion à MySQL, mais si la connexion échoue, l'affichage est mauvais :
Aucune base n'a �t� s�lectionn
Code de la connexion :
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
 
<?php 
header('Content-Type: text/html; charset=utf-8');
include 'ClassMyBdd.php';
 
MyBdd::$HOST="localhost";
MyBdd::$USER='root';
MyBdd::$PASS='';
MyBdd::$DB_NAME='forum';
 
$bdd = new MyBdd;
 
//if (!$bdd->connect()) die ('échec connexion');
 
$sql = stripslashes($_POST['requete']);
 
  $result = mysql_query($sql) or die(mysql_error());
?>
avec ClassMyBdd.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
<?php 
header('Content-Type: text/html; charset=utf-8');
class MyBdd {
	static public $DB_NAME = "---";
	static public $HOST = "---";
	static public $USER = "---";
	static public $PASS = "---";
	private $IdConn=null;
	private $isReady=FALSE;
 
    public function connect() {
		$this->IdConn=mysql_connect(MyBdd::$HOST,MyBdd::$USER,MyBdd::$PASS);
		if (!($this->IdConn)) $this->isReady=FALSE; else ($this->isReady=mysql_select_db(MyBdd::$DB_NAME,$this->IdConn));
		return($this->isReady);
	}
}
?>
Où est le problème SVP ?