What do I need to escape when sending a query?

前端 未结 11 1243
执念已碎
执念已碎 2021-01-07 18:01

When you execute a SQL query, you have to clean your strings or users can execute malicious SQL on your website.

I usually just have a function escape_string(blah),

11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-07 18:54

    For maximum security, performance, and correctness use prepared statements. Here's how to do this with lots of examples in different languages, including PHP:

    https://stackoverflow.com/questions/1973/what-is-the-best-way-to-avoid-sql-injection-attacks

提交回复
热议问题