开发者

is there anyway i can add stripslashes to all variables

adding stripslashes to all variables while retrieving from the database is driving me c开发者_如何转开发razy. is there i can do this automagically.


This is a classic sign of double-escaping. You should correct your code so it doesn't escape prematurely. To prevent SQL injection, simply use prepared statements (e.g. PDOStatement or MySQLi_STMT). You do not have to escape manually, and if you use these correctly, your database will not contain slash-escaped data.

You will have to do a one-time batch run through your database to fix the current data.


Just put the database retrieval logic into a single access point (method or class) and strip slashes there. Then all the rest of the code can use this method/class.


convert your data into array

lets for now

$data is array

array_map('stripslashes', $data); 

this will automatically add sriptslashes to every data elemnt in $data array


Disable magic_quotes everywhere

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜