2010-11-10 115 views
0

之前\使用準備好的語句來解碼BBcode,但由於某種原因,它會在發佈之前放入\'。我不知道是什麼原因造成的,但是我相信當我改變BB代碼的HTML被放在數據庫碰巧的是,代碼如下所示:準備的語句放在'

$text = $membership->remove_HTML($text); 


    //convert line breaks to <br /> tags. 
     $text = nl2br($text); 

     //cleans up by removing white space. 
     $text = trim($text); 

     //now lets replace things BASIC EDITOR 
     $text = preg_replace("/\[b\](.*)\[\/b\]/", "<strong>\\1</strong>", $text); 
     $text = preg_replace("/\[i\](.*)\[\/i\]/", "<em>\\1</em>", $text); 
     $text = preg_replace("/\[u\](.*)\[\/u\]/", "<span style='text-decoration:underline;'>\\1</span>", $text); 
     $text = preg_replace("/\[s\](.*)\[\/s\]/", "<del>\\1</del>", $text); 

     $text = preg_replace("/\[url\](.*)\[\/url\]/", "<a target='_blank' href='\\1'>\\1</a>", $text); 
     $text = preg_replace("/\[url=(.*)\](.*)\[\/url\]/", "<a target='_blank' rel='\\1' href='\\1'>\\2</a>", $text); 

     //now lets replace MORE things EXPANDED EDITOR 
     $text = preg_replace("/\[img\](.*)\[\/img\]/", "<img>\\1</img>", $text); 
     $text = str_ireplace("[hr]","<hr>", $text); 
     $text = preg_replace("/\[justify\](.*)\[\/justify\]/", "<p style='text-align:justify;'>\\1</p>", $text); 
     $text = preg_replace("/\[center\](.*)\[\/center\]/", "<p style='text-align:center;'>\\1</p>", $text); 
     $text = preg_replace("/\[left\](.*)\[\/left\]/", "<p style='text-align:left;'>\\1</p>", $text); 
     $text = preg_replace("/\[right\](.*)\[\/right\]/", "<p style='text-align:right;'>\\1</p>", $text); 
     $text = preg_replace("/\[h1\](.*)\[\/h1\]/", "<h4>\\1</h4>", $text); 
     $text = preg_replace("/\[h2\](.*)\[\/h2\]/", "<h5>\\1</h5>", $text); 
     $text = preg_replace("/\[h3\](.*)\[\/h3\]/", "<h6>\\1</h6>", $text); 

     $updatenews = $mysql->add_news($_SESSION['user'][0], $headline, $text, $time); 
+0

AAAGGHHH MY EYES !!這是怎麼回事!?這是什麼意思!? – metrobalderas 2010-11-10 01:23:24

+0

作爲一個興趣點,你可能想看看BBCode的功能。 http://uk.php.net/manual/en/book.bbcode.php – Aether 2010-11-10 10:17:30

回答

0

檢查是確保PHP的魔術引號最快的事情是disabled

如果您不想正確使用PHP配置,請在通過該系列preg_replaces()滾動$text之前查看是否存在斜槓。

+0

謝謝!我修改了我的ini文件,現在一切正常。 – 2010-11-10 02:39:54