PHP, PostgreSQL and bytea

The following two lines have been lifesavers for the situation where a picture is properly inserted into the PostgreSQL, but cannot be taken out and displayed, even if the headers and whatever else needed is properly in place:

Hope this helps somebody out there!