Why are you concatenating them in the query? Why not just implode() them after it pulls the data?
$Link = mysql_connect ($Host, $User, $Password)
or die ("The database connection could not be established!");
$query = "SELECT pic1,pic2,pic3,pic4,pic5
FROM test
WHERE id = 2";
$result = mysql_db_query ($DBName, $query, $Link);
$x = mysql_fetch_assoc($result);
extract($x);
$picArray=array($pic1,$pic2,$pic3,$pic4,$pic5);
$concat=implode(",",$picArray);