How can I avoid SQL injection attacks?

后端 未结 6 2413
轻奢々
轻奢々 2020-11-27 07:33

Yesterday I was speaking with a developer, and he mentioned something about restricting the insertions on database field, like, strings such as -- (minus minus)

6条回答
  •  Happy的楠姐
    2020-11-27 08:01

    Use parameterized queries. These queries represent the variables as a placeholder in the SQL, such as select * from person where name = ?. After creating the SQL query, you set the parameter values in the query. Parameterized queries ensure that whatever was substituted for the placeholder will not be considered as part of the SQL statement.

    See Jeff Atwood's article for a good overview of parameterized queries.

提交回复
热议问题