在对参数进行盲化并将数据插入数据库后,引号被转义为,\"
因此输出看起来很丑: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;