_POST 字段中的某些特殊字符导致 INSERT 到 MySQL 时出错
我在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看
mysql_real_escape_string()
- 通常效果很好。have a look at
mysql_real_escape_string()
- that usually works well.