This is a discussion on "Storing images as long blobs" within the PHP Forum section. This forum, and the thread "Storing images as long blobs are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Storing images as long blobs
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Storing images as long blobs
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. Thanks in advance Brian |
|
|
|
||||
|
Re: Storing images as long blobs
I don't have a lot of time, but my first thought is that this should be fairly easy, like
|
|
|||
|
Re: Storing images as long blobs
Thanks so much for your reply masonbarge...
I beleive that to be the correct way to do it but the trouble is I don't know what to assign to data because it is stored as a Long Blob in the database... should it be something like default.jpg or should it be a binary number... I am very confuesd about this little detail and would be very grateful if anyone could help me undertsand this. Thanks again |
|
|||
|
Re: Storing images as long blobs
If the default image is in the database too - say at id "zzz" - why not change your select to read
select ..... where ID = "wanted" or ID = "zzz" order by ID desc .... then you don't have to bother checking ... if the record you want exists, you get it back as the first record; if not, you get the default back as the first and only record. |
![]() |
| Tags |
| storing, images, long, blobs |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Matching HTML And Storing | josephman1988 | Other Programming Languages | 0 | Feb 18th, 2008 13:25 |
| How long? | dhall | Webforumz Cafe | 23 | Aug 29th, 2007 01:15 |
| storing lists of friends | keyboardcowboy | Website Planning | 0 | May 22nd, 2007 19:14 |
| What took me so long? | Napalm | Introduce Yourself | 3 | Jan 6th, 2005 14:43 |
| Storing and Retrieving Multiple Objects From 1 ... | courtjester | Classic ASP | 9 | Sep 12th, 2004 16:37 |