Jump to content

echoing images from my database[solved]


elexion

Recommended Posts

hello everyone, I'm trying to echo a image from my database however i'm getting a broken image in return. This is the code so far

while($row = mysql_fetch_array($query))  {$img_src = 'producten/' . $row['productname'];$image = "<img src=$img_src />";  echo "<a href='detail.php?product={$row['productname']}'>" . $row['productname'] . "</a>" . $row['console'];  echo $image;  echo "<br />";  }

As you can see the directory of the image is generated by the productname so i wonder if this might be the cause. The image is stored into my database and i can see it there. Thanks for the post in advance

Link to comment
Share on other sites

you cant access the image in db with img tag. img tag only can access image if its in webroot and if the image file exist in filesystem (it must match the directory,filename and file extension.i am not sure how you are storing the image..are you using any column in db to store the image or just filesystem?

Link to comment
Share on other sites

you cant access the image in db with img tag. img tag only can access image if its in webroot and if the image file exist in filesystem (it must match the directory,filename and file extension.i am not sure how you are storing the image..are you using any column in db to store the image or just filesystem?
i see, well the file is in my webroot i'm hosting a small site now and it's in the folder products, each product that's uploaded generates it's own folder with the productname as it's name in there is the image but i'm not sure how to display it.Edit; i use a colum to store the extension name example: image.jpg But the image does exist on the webroot
Link to comment
Share on other sites

the image will be looking for <img src=$img_src /> as a link to the image, as you have not distinguished from html code and php and not defined filename used for image from what i can see.$img_src = 'producten/' . $row['productname'];$image = "<img src=$img_src />";should be similar to$img_src = 'producten/'.$row['productname'].'/'. $row['imagefile']; $image = '<img src="'.$img_src.'" />';

Link to comment
Share on other sites

the image will be looking for <img src=$img_src /> as a link to the image, as you have not distinguished from html code and php and not defined filename used for image from what i can see.$img_src = 'producten/' . $row['productname'];$image = "<img src=$img_src />";should be similar to$img_src = 'producten/'.$row['productname'].'/'. $row['imagefile']; $image = '<img src="'.$img_src.'" />';
thank you for the help that fixed it
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...