I have a php script that goes like:-
<?php
$res = pg_query($db, "SELECT picture FROM userpost WHERE postid='2';");
$raw = pg_fetch_result($res, 'picture');
echo pg_unescape_bytea($raw);
?>
where $db
is my postgresql database.
I'm using it to display an image that I inserted in my database using the command
insert into userpost(userid,postid,picture,content) values('244','2',bytea('/home/ankit/Downloads/Photos/0.jpg'),'This is post number 3');
What I get then in my browser is the address of the image, i.e, /home/ankit/Downloads/Photos/0.jpg
and not the actual image. I can't understand what's the problem. Please help me figure it out. Thanks!