Jump to content

Decompressing Problem


deepPHP

Recommended Posts

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);
Link to comment
https://forums.phpfreaks.com/topic/281186-decompressing-problem/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.