【发布时间】:2012-10-05 15:25:38
【问题描述】:
当我尝试使用撇号提交数据时出现问题,不允许我保存到数据库中。
com0 是我的表单域。
$ucom0= mysqli_real_escape_string($_POST['com0']);
$AddQuery = "INSERT INTO database(feed1,comp1) VALUES ('".$ucom0."','".$uincrease0."')";
这是错误:
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
【问题讨论】:
-
如果您使用准备好的语句,您将完全回避这个问题。您已经在使用支持它们的 mysqli。
-
这不是人们应该回避的问题,它是理解引用标准的基础。
-
显示生成的查询。 $ucom0 不可能导致这种情况,所以很可能是 $uincrease0
-
你能给我一些示例代码吗?真的很感激。
标签: php mysql database escaping