A couple other alternatives:
$names = array();
while($row = mysql_fetch_array($res)) {
$names[] = stripslashes($row['name']);
}
echo implode(', ', $names);
// . . . or . . . //
$names = '';
while($row = mysql_fetch_array($res)) {
$names .= stripslashes($row['name']).', ';
}
echo rtrim($names, ', ');
PS: If you need to use stripslashes() for data being read from your database, there is something wrong with the way you are putting it in there (or, in fact, you do not need the stripslashes).