note 61675 deleted from function.serialize by aharvey

From: Date: Tue, 06 Nov 2012 02:10:33 +0000
Subject: note 61675 deleted from function.serialize by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191771@lists.php.net to get a copy of this message
Note Submitter: angel at support-24 dot com ---- 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.

« previous php.notes (#191771) next »