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
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
Edited by 0xMatt
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.