what the error is say is that if the if statement is not met then you have an variable that is never used, it not an error, just a warning ... I think there is a programming joke about that
Wait sorry, I misread that. You never tell the program what the value of $league_id is (the varaible is not set) , but then its asked to find a varaible and run a logic statement on it.
#You need, something like:
# $league_id = 1;
# $league_id = "";
if ($league_id=="")$league_id = get_league_id($league);
otherwise just remove the if
$league_id = get_league_id($league);