view all images in one form

Hi,
I need help in this code ,
I have table named subject ,in this table i have four fields
(id int(9) auto_increment PK, ImageTitle varchar(30), ImageSubject TEXT and Image mediumblob)
I want display all fields in one form to show me the Title ,Subject and the image!
In this code i can’t run it with the image! it’s running without Image when i removed //echo $result2[‘Image’];

Thank you :)

//view all subjects with the images in one form.
<?php
include ("condb.php");


$query="select * from subject ";
[email protected]_query($query,$con);

$result = mysql_query($query) or die('Error, query failed');

while ($result2 = mysql_fetch_array($result))
{
echo $result2['ImageTitle'];
echo"<br/>" ;
echo $result2['ImageSubject'];
echo"<br/>" 
header("Content-type: image/jpeg");
echo $result2['Image'];
echo"<hr/>" ;

}
 mysql_close();
?>

I’m presuming the image gets encoded before it gets stored into the database. Try using base64_encode() and base64_decode() (look up these functions in the PHP manual) for storing images.

On a sidenote: it’s better and easier to store images in a folder on the filesystem and store its (relative) path in the database.

Sponsor our Newsletter | Privacy Policy | Terms of Service