简体   繁体   中英

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. 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() . 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. Is there any way to process it without errors in core PHP? Also please tell me if you have solutions in Pear DB.

I am assuming users may also paste URL encoded text, so use urldecode function in PHP. That could be one of the possible cases. Another one is as you said UTF-8, in that case use MySQL's CONVERT function. I hope this helps. If possible please provide more details like for what texts you are getting this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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