I am working on a project where I have a DB_Functions.php file to store all needed PHP functions.
Here is one of them:
public function getUserByEmailAndPassword($email, $password) {
$stmt = $this->conn->prepare("SELECT id, email, encrypted_password, salt,imagen,nombre,apellidos,created_at,unique_id,nivel_usuario,verified,cel_verificado,tel FROM users WHERE email = ?");
$stmt->bind_param("s", $email);
if ($stmt->execute()) {
$stmt-> bind_result($token1,$token3,$token4,$token5,$token6,$token7,$token8,$token9, $token10,$token11,$token12,$token13,$token14);
while ( $stmt-> fetch() ) {
$user["id"] = $token1;
$user["email"] = $token3;
$user["encrypted_password"] = $token4;
$user["salt"] = $token5;
$user["imagen"] = $token6;
$user["nombre"] = $token7;
$user["apellidos"] = $token8;
$user["created_at"] = $token9;
$user["unique_id"] = $token10;
$user["nivel_usuario"] = $token11;
$user["verified"] = $token12;
$user["cel_verificado"] = $token13;
$user["tel"] = $token14;
}
// verifying user password
$encrypted_password = $user['encrypted_password'];
// check for password equality
if (password_verify($password, $encrypted_password)) {
// user authentication details are correct
return $user;
}
} else {
return NULL;
}
}
I am using the same file DB_Functions.php on two different servers.
Server 1 is a hosted web server with PHP 7.4 (ea-php74). Server 2 is a AWS Ubuntu instance with PHP 7.4.11 (Zend).
On server 1 I am not getting any error using above mentioned function.
On server 2 I am getting following error:
PHP Fatal error: Uncaught Error: Call to a member function bind_param() on bool in /var/www/html/android_api/include/DB_Functions.php:1942\nStack trace:\n#0 /var/www/html/android_api/login.php(17): DB_Functions->getUserByEmailAndPassword()\n#1 {main}\n thrown in /var/www/html/android_api/include/DB_Functions.php on line 1942
What should I do to get the function working on server 2?