MySQL Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND dead = 0 ORDER BY online DESC, r.rank_id DESC, xp DESC, p.name' at line 1

In query
SELECT r.rank AS rank_name, name, username, IF(last_action>'2017-09-20 16:48:47','online','offline') AS online FROM players p, ranks r, users u WHERE status = 0 AND p.last_action>'2017-09-17 16:58:47' AND r.rank_id = p.rank AND p.female = r.female AND u.user_id = p.user_id AND activation_code IS NULL AND referred_by= AND dead = 0 ORDER BY online DESC, r.rank_id DESC, xp DESC, p.name


/src_pages/settings.class.php:368 do_select()
/src_pages/settings.class.php:49 Settings->display_referrals()
/page.class.php:42 Settings->display()
/index.php:376 Page->display()