gpt4 book ai didi

php - 使用特殊字符的MySQL查询

转载 作者:太空宇宙 更新时间:2023-11-03 11:10:43 25 4
gpt4 key购买 nike

每次我使用 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_escape_string()应该为你逃生。

关于php - 使用特殊字符的MySQL查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8829276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com