Undefined variable in custom default.php and query doesn't work