Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Storing images as blobs in db and displaying defaults
Old 07-01-2006, 10:13 AM Storing images as blobs in db and displaying defaults
Skilled Talker

Posts: 65
Trades: 0
Hi there I am storing images in my db as long blobs and have successfully managed to display them for each record using this bit of code...

<img src="GetImage.php?ID=<?php echo $row_Recordset1['ID']; ?>"

which creates a separate request from the GetImage.php page for each record in db...

Trouble is I would like to display a default image if there is no image in the db for that record...

I realise this must be done in the GetImage.php page but I am not sure what to check for or what value to send as my default image since the blob is binary?

Here is my code for GetImage.php...

if($_GET['ID'])
{
mysql_select_db($database_The_DB, $The_DB);
$query_Recordset1 = sprintf("SELECT ID, Picture, ImageType FROM User_Details WHERE ID = '%s'",$_GET["ID"]);

$Recordset1 = mysql_query($query_Recordset1, $The_DB) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
//echo $query_Recordset1, $totalRows_Recordset1;
$data = mysql_result($Recordset1,0,"Picture");
$type = mysql_result($Recordset1,0,"ImageType");

//if ($data = "")
//$data = /Images/Home_Graphic.jpg
//$type = image/jpg

header("Content-type: $type");
echo $data;
}
?>

i would really appreciate any help on this.

Last edited by The Hick Man; 11-18-2006 at 10:12 AM..
The Hick Man is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Storing images as blobs in db and displaying defaults
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.07780 seconds with 12 queries