PHP: POST data + apostrophes

Imagine the following:

  • Form data contains an apostrophe
  • Form is being sent
  • POST data becomes serialized
  • POST data is written to the database
  • Database data is retrieved
  • Data cannot be unserialized

The problem was found in the serialized data. I tried without and with apostrophe:

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

I know the POST data has added forward slashes in quotes and apostrophes, but somewhere my forward slashes are being removed which breaks serialization. I am not using stripslashes () function anywhere - any ideas?

+2


source to share


2 answers


Are you sure the forward slashes are being added? This only happens if Magic Quotes is activated.



+1


source


If you are writing serialized data to db and not using any relationship or advanced db functionality, you can just base64 encode the serialized data before inserting into db and decode when reading.



0


source







All Articles