The jpeg image is compressed in RFC 1951 then its uploaded to the database. The compression is done from within a VB program and its saved to the database as binary.
But for some apparent reason I'm only getting this error on certain images, the ones that are larger then 40kb.
The error happens when it gets to gzinflate($imagedata);
I also separated gzinflate like NogDog stated and I still get the error.
Even without using the imagecreatefromstring and just printing the gzinflate code.