简体   繁体   English

当用撇号复制和粘贴文本时,它不会通过mysql_real_escape_string()

[英]When copy & pasting text with apostrophe it is not passing through mysql_real_escape_string()

I have added mysql_real_escape_string() with a query for text inputs. 我已经添加了mysql_real_escape_string()和一个用于文本输入的查询。 When a user writes text with symbols it passes through mysql_real_escape_string() and works fine, but when the user pastes text copied from other websites it won't pass through mysql_real_escape_string() . 当用户用符号写文本时,它会通过mysql_real_escape_string()并正常工作,但是当用户粘贴从其他网站复制的文本时,它不会通过mysql_real_escape_string() The text after the apostrophe is cut off. 撇号后的文本被切除。

How can I fix this? 我怎样才能解决这个问题?

I believe when user pastes text in input field it's not in UTF-8 encoding. 我相信当用户在输入字段中粘贴文本时,它不是采用UTF-8编码。 Is there any way to process it without errors in core PHP? 有没有办法在核心PHP中没有错误地对其进行处理? Also please tell me if you have solutions in Pear DB. 另外请告诉我您是否在Pear DB中有解决方案。

I am assuming users may also paste URL encoded text, so use urldecode function in PHP. 我假设用户也可以粘贴URL编码的文本,因此在PHP中使用urldecode函数。 That could be one of the possible cases. 那可能是其中一种情况。 Another one is as you said UTF-8, in that case use MySQL's CONVERT function. 就像您所说的UTF-8一样,在这种情况下,请使用MySQL的CONVERT函数。 I hope this helps. 我希望这有帮助。 If possible please provide more details like for what texts you are getting this problem. 如果可能,请提供更多详细信息,例如您遇到此问题的文字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM