Jump to content

[SOLVED] check if there is image in DB


cheeseus

Recommended Posts

Hello,

 

I am trying to write a check for each item in a news database - if there is an image in the 'image' row, display it, if there isn't an image, display an empty.gif instead. This is how far I got, but I'm new to php, so don't laugh too much  ;D

$image=mysql_result($godinass,$i,"image");

if(!isset($_GET['image'])) {
$imageurl = "http://mysite.com/features/".$image;
}else{
$imageurl = "http://mysite.com/images/empty.gif";
}

 

and then, further down, the script echoes the results:

 

echo '<div id=right_floated><img src=".$imageurl." border=1></div>'

 

What I've noticed is that if the statement is "!isset" the image is displayed (if there is one), if not, the X for missing image appears, while if I change the statement to "isset" the empty.gif is displayed whether or not there is an image for this particular id.

Thanks in advance to anyone who'd bother!

Link to comment
https://forums.phpfreaks.com/topic/48242-solved-check-if-there-is-image-in-db/
Share on other sites

Thanks a lot!

When I inserted this piece of code in the page source, it worked at first and the image appeared if there was one, or the blank one if there wasn't. But then, only the empty image started appearing whether or not there is an image or not :( I have no idea why :( I made no changes to the code other than type in the website address , hm...

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.