Here is the snippet of code that is causing the error.
public function storeUser($email, $password) {
    require_once 'include/user.config.inc.php';
    $uuid = uniqid('', true);
    //echo $uuid;
    $hash = $this->hashSSHA($password);
    //echo $hash;
    $encrypted_password = $hash["encrypted"]; // encrypted password
    //echo $encrypted_password;
    $salt = $hash["salt"]; // salt
    //echo $salt;
    $query = "INSERT INTO user_table (unique_id, email_id, encrypted_password, salt, created_at) VALUES ( :uuid, :email, :encrypted_password, :salt, NOW()) ";
    $query_params = array(
        ':uuid' => $uuid,
        ':email' => $email,
        ':encrypted_password' => $encrypted_password,
        ':salt' => $salt
    );
    try {
        //These two statements run the query against the database table.
        $stmt = $db -> prepare($query);
        $result = $stmt -> execute($query_params);
    } catch (PDOException $ex) {
        $response["success"] = 0;
        $response["message"] = "Database Error! Problem with first query!";
        die(json_encode($response));
    }
}
I am getting an error:
Notice: Undefined variable: db
Fatal error: Call to a member function prepare() on a non-object
It seems that $query and $query_params is causing the problem but I don't know why. It seems right to me.
Here's the other snippet of code
if ($db->isUserExisted($email)) {
             // user is already existed - error response
            $response["error"] = 2;
            $response["error_msg"] = "User already exist";
            echo json_encode($response);
        } else {
            $db->storeUser($email, $password);
        }
 
     
    