在php预处理语句

时间:2016-01-11 10:27:49

标签: php

用户提交表单中的某些文字输入将包含特殊字符,例如> < ,''%+&等 在预准备语句中,当参数声明为字符串时,将删除这些特殊字符。例如:

$text1 = 'There is 98% of >25 mm & "A category" of D++';
$stm->bind_param("s", $text1);

使用htmlspecialchars()可以解决一些但不是全部。例如,+已完全删除。插入表格时,上面的字符串显示为

There is 98% of >25 mm

如果我将&替换为and,则会插入以下内容;

There is 98% of >25 mm and "A category" of D 

有什么方法?即使htmlentities()也没有任何区别。

0 个答案:

没有答案