Hiya, i made a code for my forum does bbcode. Ive designed it so that me, the admin can input a template, such as if i wanted 🙂 the template would be a ":" and then a ")" one after another, then a function checks the post when you go to view it and see whether it has a template in it, if it doesnt it leaves it and if it does the function replaces the template with a replacment, which is also designated by the admin and stored in a database.
The problem i am having isn't so much the code not working its the code displaying an ugly looking code that looks like this:
Warning: preg_replace() [function.preg-replace]: Compilation failed: unmatched parentheses at offset 1 in /home/cricher/public_html/functions.php on line 341
Warning: preg_replace() [function.preg-replace]: Compilation failed: unmatched parentheses at offset 1 in /home/cricher/public_html/functions.php on line 346
But other than this the code works as it should do, the replacement appears and i can update it and change it and add others etc. etc. can any one help please. for reference here is the code that deals with the bbcode:
function bbcode($data) {
$sql = "SELECT * FROM forum_bbcode";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_array($result)) {
$bbcode['tpl'][] =
"/" . html_entity_decode($row['template'],ENT_QUOTES). "/i";
$bbcode['rep'][] =
html_entity_decode($row['replacement'],ENT_QUOTES);
}
$data1 = preg_replace($bbcode['tpl'],$bbcode['rep'],$data);
// the line above is live 341
$count = 1;
while (($data1 != $data) and ($count < 3)) {
$count++;
$data = $data1;
$data1 = preg_replace($bbcode['tpl'],$bbcode['rep'],$data);
// the line above is line 346
}
}
return $data;
}