What do I need to escape when sending a query?

前端 未结 11 1336
执念已碎
执念已碎 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:50

    I am not sure if MySql supports parameterized queries, if so, you should make an effort to go this route. This will ensure the users input can't do anything malicious.

    Otherwise some "bad" characters in addition to what you mentioned would be semicolon (;) and comments (-- and /* */).

提交回复
热议问题