str_replace should do it fine -
echo '<div class="teamname" rel="' . str_replace(' ', '', $member['team_name']) . '">' . $member['team_name'] . '</div>';
That will work for spaces, you could use preg_replace to remove a general whitespace pattern.
EDIT (having seen your edit!):
The preg_replace pattern you're probably after would be something like
echo '<div class="teamname" rel="' . preg_replace('/[^a-z0-9]+/i', '', $member['team_name']) . '">' . $member['team_name'] . '</div>';`
This will replace any non-alphanumeric character. If you really only want spaces, quote marks and periods, you can go back to a str_replace with an array as the search argument - it will be faster.
str_replace(array(' ','"',"'",'.'), '', $member['team_name'])