Can I protect against SQL injection by escaping single-quote and surrounding user input with single-quotes?

后端 未结 18 2419
忘了有多久
忘了有多久 2020-11-22 14:03

I realize that parameterized SQL queries is the optimal way to sanitize user input when building queries that contain user input, but I\'m wondering what is wrong with takin

18条回答
  •  攒了一身酷
    2020-11-22 14:32

    It's a bad idea anyway as you seem to know.

    What about something like escaping the quote in string like this: \'

    Your replace would result in: \''

    If the backslash escapes the first quote, then the second quote has ended the string.

提交回复
热议问题