Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Image from MYSQL database - funny characters 1

Status
Not open for further replies.
Mar 31, 2003
22
EU
Hi,

I'm trying to echo an Image (jpg) type - Longblob from a table and it outputs all funny characters.

Example :
{sí]  (¢€úÑÒ–Š(¢ŠJ(¢€ (¢€ (¢€ (¢€ (¢€“½:›Ži0ºtϵ?)M7·4€q¨ØæžsMn”JþšÝ÷vÍy¦¡µn$MzuóbÒBx⼺ôæy äÓBe95Î1ŸÆ¤n¦£4ÄzÏü#š'ýôÿüOð¤o
and this is only a small section !

I reckon it wasn't loaded correctly into the field in the first place because if I do a 'Select image from tblImage' on the command-line, I get the same as the echo(what should you see when do do a Select on the command-line for blobs)... has anyone any ideas !

 
I think you are seeing what you are supposed to be seeing.

Where are you echoing the blob contents to?

Obviously mysql doesn't have an internal image viewer to show you the image, so where exactly are you trying to view it?

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
<?php
$results = @mysql_query("Select images.image1 from images where images.adid = '$in_Num'");

$ads = mysql_fetch_array($results);
$out_Image = $ads['image'];
header("Content-type: image/jpeg");
echo "<img src=\"$out_Image\" width=\"360\" height=\"285\">";
?>
 
Yeah that's not really going to work that way.

Since the src attribute of an img tag has to be an actual file rather than the contents of the file.

You would need to do it a bit differently.
You would need a php file that retrieves the image information, and then directly echoes them out, and use that as the src of your image tag.

Example:
Code:
$results = @mysql_query("Select images.image1 from images where images.adid = '$in_Num'");
                   
$ads = mysql_fetch_array($results);
$out_Image = $ads['image'];
[red]
header('Content-Description: File Transfer');
header('Content-Type: image/jpeg');
header('Content-Length: ' . strlen($out_Image));
echo $out_Image;
[/red]

Then use tha file as the source for your image tag:

Code:
<img src='getimage.php'>



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
vacunita,

I have a simular probelem. I am also storing images in a MySQL database but my images are showing up. The problem I am having is each time I make my SQL call to get the images from the database I could have anywhere from 1 to up to 15 records in my results. I can get the first image to show up just fine but after that nothing. Is it possiable to return multipule images at once?

Thanks,

whit3fire
 
please start a new thread and reference this one.
 
Agreed, Make a New thread, and post your code, and how you are pushing out the 15 images. Obviously image tags can only show 1 image at a time.

So for starters you would need 15 image tags.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top