为sql插入转义字符串的最佳方式? [英] Best way to escape strings for sql inserts?

查看:166
本文介绍了为sql插入转义字符串的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想允许包含和的特殊字符是最好的方式来搜索和在插入语句中使用它之前,请替换每个字符串?



谢谢



重复的:防止mysql注入和跨站点脚本的最佳方法

解决方案

您应该使用参数化查询(因此通过扩展名,支持参数化查询的DB接口库),以便SQL注入不能发生。


What is the best way to escape strings for sql inserts, updates?

I want to allow special characters including ' and ". Is the best way to search and replace each string before I use it in an insert statement?

Thanks

Duplicate of: Best way to defend against mysql injection and cross site scripting

解决方案

You should be using parameterized queries (so by extension, a DB interface library that supports parameterized queries) so that SQL injection can't happen.

这篇关于为sql插入转义字符串的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆