Php 准备好的语句将\置于'

Php 准备好的语句将\置于',php,prepared-statement,Php,Prepared Statement,我正在使用准备好的语句来解释BBcode,但由于某种原因,在发布时它会将\放在“之前”。我不知道是什么原因造成的,但我确信当我将BBcode更改为html以放入数据库时,会发生这种情况,代码如下所示: $text = $membership->remove_HTML($text); //convert line breaks to <br /> tags. $text = nl2br($text); //cleans up by remov

我正在使用准备好的语句来解释BBcode,但由于某种原因,在发布时它会将\放在“之前”。我不知道是什么原因造成的,但我确信当我将BBcode更改为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);

要检查的最快的事情是确保PHP的神奇引号是正确的


如果你不想在PHP配置上乱搞,那么在你将$text滚动到这一系列preg_替换之前,先检查一下斜杠是否存在。

aaagghh MY EYES!!这是什么!?这是什么意思!?作为一个兴趣点,您可能希望查看BBCode函数。非常感谢。我修改了ini文件,现在一切正常。