note 61675 added to function.serialize
| From: | angel at support-24 dot com | Date: | Thu, 09 Feb 2006 08:25:06 +0000 |
| Subject: | note 61675 added to function.serialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-103348@lists.php.net to get a copy of this message | ||
I recently had a problem inserting serialized array in mysql DB using PEAR DB_Base class functions.
mySQL fails to insert the serialized array because the serialized data contains semicolon. A way to
solve that problem is to make same changes to the serialized data:
$serializeorder = serialize($order);
$serializeorder = preg_replace("#;#msi",'0x3B',$serializeorder);
$serializeorder = preg_replace("/(\n)|(\r)/"," ",$serializeorder);
$serializeorder = addcslashes($serializeorder, "\0..\37!@\@\177..\377");
$serializeorder = addslashes($serializeorder);
Here we substitute the semicolon with it's hex. We alse get rid of cariage return. Remember to
make the vise versa substitution again when extracting the data.
----
Server IP: 217.75.128.29
Probable Submitter: 213.91.220.158
----
Manual Page -- http://www.php.net/manual/en/function.serialize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61675
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61675&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61675&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61675&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61675&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61675&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61675&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61675&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61675&report=yes
Search -- http://master.php.net/manage/user-notes.php