可能重复:
Best way to prevent SQL injection in PHP?PHP SQL “保护” 串
我犯了一个PHP脚本ectracting XML值,并将其插入到一个SQL数据库。
但是,这些字符串具有各种符号,反斜杠,%,*,'等,而最终我会得到一个错误。
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's demanding business environment.
Product Lin' at line 2
我试图像“的stripslashes”的几件事情等卜我不能似乎找到commaned“保护”变量与我的SQL干扰。
任何想法?
您必须使用PDO。它不仅可以解决您的问题,还可以使您的脚本远离注入攻击更安全。 http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ PDO文档:http://php.net/manual /en/book.pdo.php –