Check that $_SERVER['SERVER_NAME'] is exists before use correctly.