每次使用SQL查询插入数据时都会出现错误。我怀疑是因为$post
值中有撇号。
SQL查询是:
$sql="INSERT INTO posts (id_str, post, time, rt) VALUES ('$id_str','$post', '$time', '$rt')";
但是我的$post
值是
$post = "My test posts are not as 'inconsistent' as before";
我该怎么办?
mysql_real_aescape_string()应该为您执行转义。
最基本的解决方案是mysql_real_escape_string()
。