Functions.php file
include __DIR__ . "/mysql.php"; function checkPassword($pass, $email){ $mysql = new Mysql(); $sql = "SELECT * FROM users where `email` = ':email' AND `password` = ':password'"; $params = [':email' => $email, ':password' => md5($pass)]; var_dump($mysql->query($sql, $params)); } The query function from mysql.php
public function query($sql, $params=[]) { try { $sth = $this->db->prepare($sql); $sth->execute($params); return $sth->fetchAll(PDO::FETCH_OBJ); } catch (PDOException $e) { echo 'Ошбика при выполнение запроса: ' . $e->getMessage(); } } I check the function in index.php
include(__DIR__. '/core/functions.php'); checkPassword('123123','qwe@mail.ru'); And he just shows me:
array (0) {}
In the specified parameters, everything is correct, checked through phpMyAdmin there it finds.
SELECT * FROM users where
password= MD5 ('123123')
Here is the screen:
I tried to change the SQL query to this:
$ sql = "SELECT * FROM users";
And I have everything brought out, brought all users. It turns out the problem is somewhere with the $ params array or something else, I can not understand ...
