user15063
user15063

Reputation:

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

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

Upvotes: 1

Views: 1999

Answers (1)

karim79
karim79

Reputation: 342655

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.

Upvotes: 6

Related Questions