开发者

PHP: POST data + apostrophes

Imagine this:

  • Form data contains an apostrophe
  • Form gets submitted
  • POST data gets serialized
  • POST data is written to database
  • Database data is retrieved
  • Data cannot be unserialized

The problem is found in the serializ开发者_StackOverflow中文版ed data. I tried without and with an apostrophe:

  • s:7:"company";s:12:"Joes company"
  • s:7:"company";s:14:"Joe's company"

I know POST data adds slashes to quotes and apostrophes but somewhere my slashes are being removed which is breaking the serialization. I'm not using the stripslashes() function anywhere - any ideas?


Are you sure the slashes are getting added? That only happens if Magic Quotes is enabled.


If you are writing serialized data into the db and not making use of any relations or advanced db functionality, you can simply base64 encode the serialized data before inserting into db, and decode when reading back.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜