Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 删除转义字符_Php_Mysql_Variables - Fatal编程技术网

Php 删除转义字符

Php 删除转义字符,php,mysql,variables,Php,Mysql,Variables,好的,假设我有一些用户输入,可以从mysql数据库中选择一些内容 我想避免mysql注入,所以为了做到这一点,我会使用mysql\u real\u escape\u string()函数。但是在那之后,我想从我的字符串中完全去掉引号或任何不好的东西 示例-: my title variable = Herp' escape with mysql_real_escape_string().... then my variable = Herp\' 现在,我想把这句不好的话说出来。因此,我想删除

好的,假设我有一些用户输入,可以从mysql数据库中选择一些内容

我想避免mysql注入,所以为了做到这一点,我会使用mysql\u real\u escape\u string()函数。但是在那之后,我想从我的字符串中完全去掉引号或任何不好的东西

示例-:

my title variable = Herp'
escape with mysql_real_escape_string()....
then my variable = Herp\' 
现在,我想把这句不好的话说出来。因此,我想删除反斜杠后面的反斜杠和字符。。所以它看起来像“Herp”

我该怎么做

很抱歉,这让人困惑。

请使用


但我想知道为什么会这样。检查您的设置。出于安全原因,如果您只想过滤掉引号而不是转义引号,那么将其设置为“关闭”好吗

$myTitleVar = str_replace(array("'", '"'), '', $myTitleVar);

在将其插入数据库之前,我仍然建议通过
mysql\u real\u escape\u string()
运行它,或者更好地使用PDO和参数绑定。

那么,您想从输入中删除撇号吗?角色从来都不是“坏的”。你要么想要,要么不想要。如果你逃离了他们,你就没有什么好害怕的了。那只是去掉了斜杠,没有多余的字符。。。如果我运行它,它基本上会撤消mysql_real_escape_string();