On 2009-05-01, Tomas Vondra <tv@fuzzy.cz> wrote:
> Hi,
>
> I've run into some strange troubles with a quite simple web application
> that stores data in a PostgreSQL database. It is a simple image gallery,
> displaying multiple thumbnails (stored in a bytea column) on a single
> page generated by PHP. The problem is some of the images are not displayed.
>
> $conn = pg_connect(...);
> $res = pg_query("SELECT mime, thumbnail_data FROM images WHERE filename
>= ....");
> $row = pg_fetch_assoc($row);
> header('Content-Type: ' . $row['mime']);
> echo pg_unescape_bytea($row['thumbnail_data']);
This is cut-n-paste from a working site (pg 7.4, PHP 4.3.9)
$res=pg_query("select * from images where id='$id' ;");
$row=pg_fetch_assoc($res);
header("content-type: $row[type]");
echo pg_unescape_bytea($row['data']);
the date on the file is NOV 19 2006.
wasn't I a crap programmer back then :)