PROBLEME CONNECTION BDD
Posté : 09 juin 2016, 09:49
Bonjour, bonsoir,
J'ai besoin de votre aide.
Voici ma fonction dans une classe gestionOrdi :
Voici mon fichier connect :
Dans mon controler j'appelle ma fonction lecture :
Et une erreur s'affiche;
Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'root'@'monIP' (using password: YES)' in (chemin)\gestionOrdi.class.php:122 Stack trace: #0 (chemin)\gestionOrdi.class.php(122): PDO->__construct('mysql:host=monIP', 'monUser', 'monMDP', Array) #1 (chemin)\afficheOrdi.php(3): gestionOrdi::lecture() #2 (chemin)index.php(25): include('chemin') #3 {main} thrown in(chemin)\gestionOrdi.class.php on line 122
Je ne comprend pas mon erreur sachement que j'ai tout correctement respecter.
Merci d'avance !
J'ai besoin de votre aide.
Voici ma fonction dans une classe gestionOrdi :
Code : Tout sélectionner
static function lecture(){
include('include/connect.php');
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=' . $host . ';dbname=' . $dbname, $utilisateur, $mdp, $pdo_options);
$req= $bdd->query("SELECT name FROM glpi_computers");
$TableauOrdi = array();
try
{
while($ligne=$req->fetch())
{
$TableauOrdi[] = new Ordinateur($ligne["name"]);
}
$req->closeCursor();
return $TableauOrdi;
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
}Voici mon fichier connect :
Code : Tout sélectionner
<?php
$host=' '; -> IP de la BDD que je cache
$dbname='glpi';
$utilisateur=''; -> user que je cache
$mdp=' '; -> mdp que je cache
?>
Code : Tout sélectionner
<?php
require('model/gestionOrdi.class.php');
$ordinateurs = gestionOrdi::lecture();
include('view/afficheOrdi.php');
?>Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'root'@'monIP' (using password: YES)' in (chemin)\gestionOrdi.class.php:122 Stack trace: #0 (chemin)\gestionOrdi.class.php(122): PDO->__construct('mysql:host=monIP', 'monUser', 'monMDP', Array) #1 (chemin)\afficheOrdi.php(3): gestionOrdi::lecture() #2 (chemin)index.php(25): include('chemin') #3 {main} thrown in(chemin)\gestionOrdi.class.php on line 122
Je ne comprend pas mon erreur sachement que j'ai tout correctement respecter.
Merci d'avance !