Shouldn't mysql_real_escape_string() leave slashes in Database?

后端 未结 1 431
青春惊慌失措
青春惊慌失措 2021-01-20 13:10

Im using smarty and mysql_real_escape_string() for user input, and when I insert some code with \' or \" , and lookup in phpmyadmin it

1条回答
  •  不思量自难忘°
    2021-01-20 14:02

    You're missing it - escaping with backslashes is meant to ensure that queries aren't malformed, e.g. something like this will surely break and possibly risk SQL injections:

    insert into table values ('whatever 'this' is')
    

    and nothing will be saved in the table, whereas this:

    insert into table values ('whatever \'this\' is')
    

    will save the value "whatever 'this' is" in the table.

    0 讨论(0)
提交回复
热议问题