Hey guys...

I'm working on a blog farm of sorts and on the main page I have a section which shows the recent posts from one of eight blogs.

The posts are being updated correctly but it does away with line breaks and changes apostrophes to question marks.

Here is my recent.php file:

PHP Code:
<?
    $blog_prefix 
"redesign/blogs/WordPress";
    
    
$conn[] = mysql_connect("localhost","user","pass");
    
$conn[] = mysql_connect("localhost","user-1","pass");
    
$conn[] = mysql_connect("localhost","user-2","pass");
    
    
    
$where " where post_status='publish' AND post_type='post' order by post_date DESC LIMIT 0,10";
    
$result[] = mysql_query("select * from substance.wp1_posts".$where,$conn[0]);
    
$result[] = mysql_query("select * from substance.wp2_posts".$where,$conn[0]);
    
$result[] = mysql_query("select * from substance.wp3_posts".$where,$conn[0]);
    
mysql_select_db("substance-1",$conn[1]);
    
$result[] = mysql_query("select * from wp4_posts".$where,$conn[1]);
    
$result[] = mysql_query("select * from wp5_posts".$where,$conn[1]);
    
$result[] = mysql_query("select * from wp6_posts".$where,$conn[1]);
    
mysql_select_db("substance-2",$conn[2]);
    
$result[] = mysql_query("select * from wp8_posts".$where,$conn[2]);
    
$result[] = mysql_query("select * from wp9_posts".$where,$conn[2]);
    
    
mysql_close($conn[0]);
    
mysql_close($conn[1]);
    
mysql_close($conn[2]);

    
$j=0;
    for(
$i=0;$i<8;$i++){
        while(
$row mysql_fetch_array($result[$i])){
            
$res[$j][pid]=$row[ID];
            
$res[$j][blogid]=$blog_prefix.($i+1);
            
$res[$j]['post_date']=$row[post_date];
            
$res[$j][post_title]=$row[post_title];
            
$res[$j][post_content]=utf8_decode($row[post_content]);
            
$j++;
        }
    }

$res  msort($res,'post_date');
$res  array_slice($res,0,10);
/*for($i=0;$i<sizeof($rows);$i++){
print_r($rows[$i]);
}*/


/*
for($i=0;$i<6;$i++){
    while($row = mysql_fetch_array($result[$i])){
        $sql = "insert into temp_posts(pid,blogid,post_date,post_title,post_content) values(".$row[ID].",".($i+1).",'".$row[post_date]."','".$row[post_title]."','".$row[post_content]."')";
        //echo $sql.";<br>";
        mysql_query($sql);
    }
}


//$res = search($search,$limit,$page)
$sql = "select * from temp_posts order by post_date DESC LIMIT 0,10";
$res = mysql_query($sql);
*/
/*echo ("<h2>Recent Posts</h2>");

while($row = mysql_fetch_array($res)){
    // use if $row[guid]
    echo "<a href=$blogurl/".$row[blogid]."/?p=".$row[pid].">".$row[post_title]."</a><br>";
    echo parsecontent($row[post_content])."<br><br>";
}*/


function parsecontent($text){
    
$offset 400;
    
$ext " ";
    
$patterns "/\<(.*?)\>/";
    
$replacements "";
    
$newText preg_replace($patterns,$replacements$text);
    if(
strlen($newText)<400){
        
$offset strlen($newText);
        
$ext "";
    }
    
$pos strpos($newText ," "$offset);
    if(!
$pos)
        
$pos 400;
    return 
substr($newText,0,$pos).$ext;
}


function 
msort($array$id="id") {
        
$temp_array = array();
        while(
count($array)>0) {
            
$lowest_id 0;
            
$index=0;
            foreach (
$array as $item) {
                if (isset(
$item[$id]) && $array[$lowest_id][$id]) {
                    if (
$item[$id]>$array[$lowest_id][$id]) {
                        
$lowest_id $index;
                    }
                }
                
$index++;
            }
            
$temp_array[] = $array[$lowest_id];
            
$array array_merge(array_slice($array0,$lowest_id), array_slice($array$lowest_id+1));
        }
        return 
$temp_array;
    }
?>
Any idea what is causing this?
Here is the live demo