View Full Version : BB code in PHPbb


TanisLinkEragon
12-17-2006, 07:54 PM
Hey guys, I'm attempting to take some posts made in my forum (phpbb) and put them outside of the form (like a portal)

Its working fine, and I get the posts, only problem is BB code...

say someone posts

Cool.


When I get it out of my database, and put it somewhere, it shows up as

cool


It does the same thing if you use HTML in your post.
BB code is stored into the database as plain BB code, but since phpbb3 doesn't allow HTML, it gets stored into the database with < and >

The best solution would probably be some way to decode the BBcode and change it into HTML. Any suggestion?

Current code:

<?php
$con = mysql_connect("my host","my username","my password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my DB", $con);

$result = mysql_query("SELECT * FROM phpbb_posts WHERE forum_id='39' ORDER BY post_subject");

while($row = mysql_fetch_array($result))
{
?><font color=#C7C7C7>
<?php
echo $row['post_text'];?>
<br><br>
<img src="/divide.jpg"><br><br>
<?php

}

mysql_close($con);
?>

note: the <br><br>
<img src="/divide.jpg"><br><br> is there to separate the posts, and the font color tag is there to, well, change the font color.

EhraniNavy
12-22-2006, 03:24 AM
You can use something like

$string = ereg_replace("[b]", "<b>", $string);

I think that would work in PHP.

Or you could add javascript

string = string.replace(/[b]/gi, "<b>");

Which would effectively do the same thing.