_POST 字段中的某些特殊字符导致 INSERT 到 MySQL 时出错

发布于 2025-01-04 00:14:19 字数 252 浏览 4 评论 0原文

我在 MySQL 中有一个简单的 Web 表单和一个简单的后端表。由于特殊字符的存在,我在某些帖子中看到语法错误。

我正在使用 stripslashes($_POST['form_field']) 但写入数据库时​​仍然出错。

我在这里寻求一些快速帮助,看看是否有人知道正确的 PHP 函数,以便在写入表之前更好地清理我的传入数据。

我不想用每一个特殊字符(总共 32 个)逐一测试我的表单,以捕获并隔离那些罪魁祸首。

谢谢。

I have a simple web form and a simple backend table in MySQL. I am seeing syntax errors in certain posts due to the presences of special characters.

I am using stripslashes($_POST['form_field']) but I still get errors writing to the database.

I am looking for some quick help here to see if anyone knows of the right PHP function to better cleanse my incoming data prior to writing to the table.

I prefer not to test my form, one-by-one, with every single special character (32 in all) to catch and isolate those that are the culprits.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷了相思 2025-01-11 00:14:19

看看 mysql_real_escape_string() - 通常效果很好。

have a look at mysql_real_escape_string() - that usually works well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文