Regular Expression Error : Uknown modifier error

Can someone help me with this error message :

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'b' in C:\wamp\www\outputfunctions.php on line 37

Here’s the function :

function bbcode($data) {
  $sql = "SELECT * FROM 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);
    $count = 1;
    while (($data1 != $data) and ($count < 4)) {
      $count++;
      $data = $data1;
      $data1 = preg_replace($bbcode['tpl'],$bbcode['rep'],$data);
    }
  }

  return $data;
}

Here’s the table :


CREATE TABLE IF NOT EXISTS bbcode (
  id int(11) NOT NULL auto_increment,
  template varchar(255) NOT NULL default '',
  replacement varchar(255) NOT NULL default '',
  PRIMARY KEY  (id)
)ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

-- 
-- Dumping data for table `bbcode`
-- 

INSERT INTO `bbcode` VALUES (1,'\[b\]([^[]+?)\[/b\]','<b>$1</b>');


Other Info : PHP 5 MySql : 5.0.22

Thanks a lot