function to sanitize input to Mysql database

前端 未结 5 2143
春和景丽
春和景丽 2020-12-14 03:19

I am trying to put a general purpose function together that will sanitize input to a Mysql database. So far this is what I have:

function sanitize($input){
          


        
5条回答
  •  春和景丽
    2020-12-14 03:36

    the worst part that adding slashes does not sanitize anything, no matter what function was used.
    and it should not be used in the means of whatever "sanitization" at all.

    slashes do not "sanitize" data. Slashes do escape string delimiters only. Thus, the only sanitization you can talk of, is escaping and and quoting.

    Otherwise, if you won't put quotes around "sanitized" string, you will have no protection at all.

提交回复
热议问题