Functions.php file
include __DIR__ . "/mysql.php"; $mysql = new Mysql(); function checkPassword($pass, $email){ $sql = "SELECT * FROM user where `email` = :email AND `password` = :password"; $params = [':email' => $email, ':password' => md5($pass)]; //var_dump($params); var_dump($mysql->query($sql, $params)); } The query function from mysql.php
public function query($sql, $params=[]) { $sth = $this->db->prepare($sql); $sth->execute($params); return $sth->fetchAll(PDO::FETCH_OBJ); } I check the function in index.php
include(__DIR__. '/core/functions.php'); checkPassword('123123','qwe@mail.ru'); And I have such a mistake.
Fatal error: Call to a member function query () on null in E: \ OpenServer \ OpenServer \ domains \ blackmarket \ core \ functions.php on line 9
I can not understand what is wrong ?! All variables are not empty, that he does not like that ((