我使用addslashes()来插入数据。但服务器本身也会添加addslashes()。
例如:
$str="jogindersinh's company";
$q="insert into company(company_nm)values(addslashes($str))";字符串必须插入到数据库中,如jogindersinh's company。
但由于二次添加addslashes(),数据插入到jogindersinh\'s company等数据库中。
所以当我获取数据时。获取结果jogindersinh\'s company。
那么如何停止服务器来添加addslashes()呢?
发布于 2014-04-17 02:08:58
听起来像是启用了Magic Quotes。你应该把它关掉。
除此之外,addslashes()不会保护您免受sql注入的影响。您应该改用准备好的语句(如果需要,也可以使用专用的转义函数,如mysql_real_escape_string() )。
发布于 2014-04-17 02:11:55
查看您的php设置文件并禁用Magic Quotes。同时保护您的查询不受sql注入的影响。尝试使用Ctype_和Mysql_real_escape_string()验证输入。
https://stackoverflow.com/questions/23116942
复制相似问题