Call to a member function fetch() on a non-object
Bonjour à tous,
j'ai un message d'erreur comme l'intitulé, voilà mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public function isLogin($username, $password){
$pdo=$this->getPdo();
$valeur = "admin";
echo $valeur;
$res = $pdo->query("select * from user where username=".$valeur);
if ($res === false){
$errorInfo = $pdo->errorInfo();
//log the error or take some other smart action
}
$article=$res->fetch(PDO::FETCH_OBJ);
$res->closeCursor();
var_dump($article);
exit();
} |
Mon getPdo
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
public function getPdo(){
if($this->pdo==null){
try
{
$PARAM_port='3306';
$pdo=new PDO('mysql:host='.$this->dataBase['dbHost'].';port='.$PARAM_port.';dbname='.$this->dataBase['dbName'],$this->dataBase['dbUser'] , $this->dataBase['dbPassword']);
}
catch(Exception $e)
{
echo 'Erreur : '.$e->getMessage().'<br />';
echo 'Num : '.$e->getCode();
}
return $pdo;
}
else
return $this->pdo;
} |
si je met select * from user sa marche bien !
Merci d'avance