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

后端 未结 18 2439
忘了有多久
忘了有多久 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:26

    While you might find a solution that works for strings, for numerical predicates you need to also make sure they're only passing in numbers (simple check is can it be parsed as int/double/decimal?).

    It's a lot of extra work.

提交回复
热议问题