Pulling Images out of a BLOB in mySQL
Posted: Tue Sep 07, 2010 2:12 am
Hi everyone,
I currently have a page uploading images 2 ways. one of which is a thumbnail to a BLOB file in mySQL. I know that this is not always the best way but for this purpose it fits well.
My problem is that I seem to have got the data in to the DB fine but I cant seem to pull it back out..
The code for the page where I want to retrieve it below and the name of the pictures in the mySQL db is thumb. I want the testimage.jpg to be replaced by the image stored as a BLOB.
Thanks in advance for any help.
I currently have a page uploading images 2 ways. one of which is a thumbnail to a BLOB file in mySQL. I know that this is not always the best way but for this purpose it fits well.
My problem is that I seem to have got the data in to the DB fine but I cant seem to pull it back out..
The code for the page where I want to retrieve it below and the name of the pictures in the mySQL db is thumb. I want the testimage.jpg to be replaced by the image stored as a BLOB.
Thanks in advance for any help.
Code: Select all
<?php
$sql = "SELECT * FROM mydatabase ORDER BY id DESC";
$result = mysql_query($sql) or die (mysql_error());
while($row = mysql_fetch_array($result))
{
$id = $row['id'];
echo "<img src=\"testimage.jpg\" alt=\"\" name=\"image\" width=\"64\" height=\"48\" align=\"left\" id=\"image\" style=\"background-color: #000099\" /><p class=\"newsArticleTxt\"><strong>" . $row['newstitle'] . "</strong><br /><small>" .$row['newscaption'] . "<BR />";
echo "<a href='displaynews.php?id=".$id."'>Read article</a></small></p>><hr>";
}
?>