MMMHUHU
如果将此数据提交给数据库,请查看数据库的转义函数。也就是说,对于MySQL来说MySQL真实转义字符串.这些转义函数处理任何可能是恶意的字符,您仍将以相同的方式获取数据。您还可以使用准备好的语句来处理数据:$dbPreparedStatement = $db->prepare('INSERT INTO table (htmlcontent) VALUES (?)');$dbPreparedStatement->execute(array($yourHtmlData));或者再自我解释一下:$dbPreparedStatement = $db->prepare('INSERT INTO table (htmlcontent) VALUES (:htmlcontent)');$dbPreparedStatement->
execute(array(':htmlcontent' => $yourHtmlData));如果要保存不同类型的数据,请使用bindParam若要定义每种类型,即可以通过以下方法定义整数:$db->bindParam(':userId', $userId, PDO::PARAM_INT);..例子:$dbPreparedStatement = $db->prepare('INSERT INTO table (postId, htmlcontent) VALUES (:postid, :htmlcontent)');
$dbPreparedStatement->bindParam(':postid', $userId, PDO::PARAM_INT);$dbPreparedStatement->bindParam(':htmlcontent',
$yourHtmlData, PDO::PARAM_STR);$dbPreparedStatement->execute();哪里$db是PHP数据对象(PDO)。如果你不使用它,你可以在PHP数据对象.