输出显示转义的引号


Output is showing the escaped quotation marks

在屏蔽参数并将数据插入数据库后,quotaion被转义为'",因此输出看起来很难看,如:hello this is an output test '"test '"
如何使引号正常显示

以下是我如何将数据插入数据库

if( $_POST )
{
   include "db.php";
    $title = $_POST['title'];
    $content = $_POST['content'];
    if(strlen($title) >= 77) { die('large_title'); };
    if(strlen($content) <= 19) { die('low_content'); };
    if(empty($title)) { $title = 'EMPTY00'; }
 $stmt = $mysqli->prepare("INSERT INTO na_posts(title,content) VALUES (?, ?)");
 $stmt->bind_param("ss",$title,$content);
 $stmt->execute();
 $stmt->close();
      $content = htmlspecialchars(mb_substr($content, 0, 125,'utf-8'));
      echo $content.'...';
} else { die('error'); }

这是我的输出代码:

$content = nl2br(htmlspecialchars($row->content));
echo $content;

在数据库中插入数据时,有些代码会添加不必要的斜杠。

它要么是magic_quotes,要么是代码中某个地方的某种addslashes()/mysql_real_eescape_string()除掉他们中的任何一个

使用stripslashes

$content = nl2br(stripslashes(htmlspecialchars($row->content)));
echo $content;