开发者

How do you stored a php serialized array in mysql with values that contain apostrophes?

开发者 https://www.devze.com 2023-01-01 05:48 出处:网络
I have a listing of names, that I want to store in mysql as a serialized array (for caching purposes). Some names contain apostrophes开发者_StackOverflow社区, and for some reason won\'t un-serliaze pr

I have a listing of names, that I want to store in mysql as a serialized array (for caching purposes). Some names contain apostrophes开发者_StackOverflow社区, and for some reason won't un-serliaze properly. There is no output.


Use mysql_real_escape_string on the serialized string prior to inserting into the database. You could handle storing serialized data bybase64_encodeing it prior to inserting it in the database, and base64_decodeing it upon retrieval, but with proper escaping that is unnecessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号