image from database displays funny characters on webpage

images php coding issues or problems here.

Moderators: macek, egami, gesf

jayjaz
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Apr 11, 2011 8:47 am
Location: london

image from database displays funny characters on webpage

Postby jayjaz » Mon Apr 11, 2011 9:03 am

Hello everyone, I am a newbie, I have just managed to store images in my database So far I have been able to retrie other information from the table but the image field(data) keeps displaying funny characters on my website instead of the actual image. Please help me as I have a deadline for this.

Thank you

here is a sample code of how I tried to retrieve the images' row

<?php


$img = mysql_query("SELECT id, data, title from {$table}");

while ( $row = mysql_fetch_array($img) )
{
echo("Image: ".$row["id"]."<br>");
echo(" - display image: ".$row["data"]."<br>");
}
?>

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: image from database displays funny characters on webpage

Postby johnj » Tue Apr 12, 2011 10:03 pm

how are you displaying the image?

jayjaz
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Apr 11, 2011 8:47 am
Location: london

Re: image from database displays funny characters on webpage

Postby jayjaz » Wed Apr 13, 2011 10:35 pm

I am trying to call the images from the database from the table 'admin', field for stored images is called 'data'

the titles, ids are diplaying fine, just the images i am having problems with.

please help me

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: image from database displays funny characters on webpage

Postby johnj » Thu Apr 14, 2011 2:08 am

From the table, read the image data and save it to a file. Open the saved file using a browser or some image viewing client. If you cannot do this then your image data is corrupted.

jayjaz
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Apr 11, 2011 8:47 am
Location: london

Re: image from database displays funny characters on webpage

Postby jayjaz » Thu Apr 14, 2011 2:39 am

do u know how to write the code to do that, that will save me time, please

thanks


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest