Page 1 of 1

mySQL +images help!

Posted: Wed Apr 20, 2005 10:18 pm
by Klavier
hi ok i am working with mySQL; pulling images into a table, i have the files showing correctly on one page, but not on this page.. i don't know why. all i get are broken images. heres what i am using

Code: Select all

<img src="/image/<?php echo$row["itemImage"]; ?>" >

Posted: Wed Apr 20, 2005 10:52 pm
by Todd_Z
Can you post what outputs you are getting - what are the locations of the broken images? There are hundreds of reasons that this could not be working for u.

Re: mySQL +images help!

Posted: Thu Apr 21, 2005 2:05 am
by Chris Corbyn
Klavier wrote:hi ok i am working with mySQL; pulling images into a table, i have the files showing correctly on one page, but not on this page.. i don't know why. all i get are broken images. heres what i am using

Code: Select all

<img src="/image/<?php echo$row["itemImage"]; ?>" >
Hmmm... how are you actually retreiving the data from the database?

Do you do it the exact same way on your working page?

I would have throught you'd have to have a PHP script dedicated to serving the images, which specifies the correct content-type in the headers.

Code: Select all

&lt;img src=&quote;getImage.php?img=23&quote;&gt;
EDIT | Unless you're just getting the image names from the DB.... not the image file itself?

Posted: Thu Apr 21, 2005 4:52 am
by malcolmboston
eg

Code: Select all

$query = "SELECT image_url FROM table WHERE id = '{$id}'";
$result = mysql_query($result) or die (mysql_error());
while ($array = mysql_fetch_array($result))
{
  print "<img src=\"images/{$array['image_url']}\">";
}

Posted: Thu Apr 21, 2005 10:14 am
by pickle
like ~d11wtq said, all you're doing is dumping binary data to the browser. Unless proper headers are sent, it's not going to know what to do. Your best bet is to have a special image outputing page that attaches the appropriate headers along with the binary data.

Posted: Thu Apr 21, 2005 12:24 pm
by Todd_Z
There are too many scenarios - Klavier => Post the script so that we can see whats going on