Forum Moderators: coopster

Message Too Old, No Replies

gzcompress

         

vasile_radu

7:19 am on Apr 12, 2007 (gmt 0)

10+ Year Member



Hi, if anybody can tell me why the following script gives me an error if
I comment line 3 and uncomment line 4. Thanks :)

<?php
$compressed = gzcompress('Compress me to',0);
$size = strlen($compressed);
//$size = 1;
$uncompressed = gzuncompress($compressed,$size);
echo $uncompressed;
?>

phparion

10:00 am on Apr 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I comment line 3 and uncomment line 4.

because line three defines $size, when you comment it parser skip this line and in line # 4 you are using $size so it might be getting confused there and showing error.

you didn't tell what error you are getting though?

justageek

5:20 pm on Apr 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are telling the uncompress function to only uncompress 1 byte and the data is much bigger than that so you get an error. Just remove the arguement from the function if you want the whole thing to uncompress. Then you can comment lines 3 and 4 and be done with it.

JAG

vasile_radu

10:03 am on Apr 13, 2007 (gmt 0)

10+ Year Member



Hi,

this small issue is in fact from a bigger problem, I have to obtain info about avi, mov, wmv remote files. So, I can't afford to copy the files local in order to detect it's proprieties, I only read the header of the file (first 1024 bits) and for those I have to run the decompression function. The example I've posted gave the same error, when choosing


$size = 1;

that is:

Warning: gzuncompress() [function.gzuncompress]: buffer error in C:\web\lightbt\test3.php on line 5

So, the problem rest in the fact I must decompress the first n chars of an encrypted string, where n<strlen(string).

Thanks for your answer,
Radu.