deepPHP Posted August 15, 2013 Share Posted August 15, 2013 I insert big data into database hence those data should be compressed for memory less. I compress those data with base64, gzcompress and serialize the data. but when I want to select all my data records I'm getting decompressing error. unserialize(): Error at offset 0 of 796 bytes I inserted data in that order: base64_encode(gzcompress(serialize($data); I selcet data in the opposite order: base64_decode(gzuncompress(unserialize($data); Quote Link to comment Share on other sites More sharing options...
0xMatt Posted August 15, 2013 Share Posted August 15, 2013 (edited) Not only should you have used the opposite functions but you should have called them oppositely as well. <?php $array = array('one','two','three'); $compressed = base64_encode( gzcompress( serialize($array) ) ); $uncompressed = unserialize( gzuncompress( base64_decode($compressed) ) ); print_r($uncompressed); // prints Array ( [0] => one [1] => two [2] => three Edited August 15, 2013 by 0xMatt Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.