Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unserialize problem in php

i'm using serialize/unserialize functions in php 5.2. the text to be stored is POSTed via a form. btw, no white-space before or after. if text contains " or ' it serializes successfully. the problem is it does not unserialize back. what i'm doing wrong?

like image 646
opteronn Avatar asked Dec 13 '22 21:12

opteronn


1 Answers

David Walsh has a simple solution:

//to safely serialize  
$encoded_serialized_string = base64_encode(serialize($your_array));  

//to unserialize  
$array_restored = unserialize(base64_decode($encoded_serialized_string));  

http://davidwalsh.name/php-serialize-unserialize-issues

like image 198
Eclectic Avatar answered Dec 26 '22 03:12

Eclectic