Convert new lines in xf_post.message to HTML

I'm displaying a news feed on my home page by retrieving the latest threads in a certain set of nodes from the db and subsequently retrieving the messages belonging to their OPs. The messages appear to be stored with new lines and all in the db, but as soon as I put them in a paragraph it displays as one large continues string.

Live demo:
Code that retrieves the message:
$sql = "SELECT message FROM xf_post WHERE post_id = " . $post_id . ";";
$result = $db->query($sql);
if ($result->num_rows > 0) {
    $row = $result->fetch_assoc();
    $message = $row['message'];
Am I missing a certain character I should call str_replace('char', '<br />', $message); on or am I losing the new lines all together via the way I'm retrieving the data?
Is there no way to detect the new lines at all? The URLs aren't the problem, I just haven't gotten round to them yet. But from the looks of it I got nothing to work with to parse the new lines myself.


Well-known member
You can render the parser with this code. It is untested though, but it must work.

$parser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_AutoLink', false));

$message = $parser->render($message);