note 15710 deleted from function.unserialize by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 03:21:19 +0000 |
| Subject: | note 15710 deleted from function.unserialize by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58503@lists.php.net to get a copy of this message | ||
Note Submitter: mikemindel@wordtracker.com
----
When you serialize a variable using serialize(addslashes(variable)) before placing it into a MySql
database, just use unserialize(variable) and not unserialize(stripslashes(variable)) when attempting
to retrieve it.
The reason is that MySql will remove the slashes anyway when it stores the variable. All that
happens when you strip slashes on the retrieved variable is that you are setting yourself up for a
failed unserialize. Say you had r/3 as one of your entries and this becomes r3 after the strip
slashes, unserialize will fail.
So: unserialize(variable) not unserialize(stripslashes(variable)) when retrieving from MySql
database.