Jens
Well-Known Member
Hi coders of Final Gear!
I'm working on a blog and I'm trying to display a .JPEG image from my database.
I have a table called tblnews with id, date, title, content, author and the image as a longblob.
Here's the code:
and the HTML is
To get the data such as title and content I use another script that works, but the image is doesn't show. Do I have to combine the two scripts or perhaps a new table just for images...
Or is my script just plain wrong?
Thanks in advance.
I'm working on a blog and I'm trying to display a .JPEG image from my database.
I have a table called tblnews with id, date, title, content, author and the image as a longblob.
Here's the code:
Code:
<?php
include( 'sql_connect.php' );
$image = stripslashes($_REQUEST[imname]);
$rs = mysql_query("select * from tblnews where filename=\"".
addslashes($image).".jpg\"");
$row = mysql_fetch_assoc($rs);
$imagebytes = $row[image];
header("Content-type: image/jpeg");
print $imagebytes;
?>
and the HTML is
Code:
<img src= picscript.php?imname=test>
To get the data such as title and content I use another script that works, but the image is doesn't show. Do I have to combine the two scripts or perhaps a new table just for images...
Or is my script just plain wrong?
Thanks in advance.
Last edited: