To uncompress in PHP a string that has been compressed using MySQL's COMPRESS() function, you need to discard the first four bytes of the binary data:
<?php
/*
* Example:
*
* insert into mytable (myfield, ...) values (COMPRESS('foobar'), ...)
*
* then:
*/
$compressed = //...select myfield from mytable where...
/*
* then:
*/
$uncompressed = gzuncompress(substr($compressed, 4));
?>
Of course, you can use MySQL's UNCOMPRESS() function.
I was just providing an alternate method.