cheeseus Posted April 23, 2007 Share Posted April 23, 2007 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 $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 More sharing options...
Mutley Posted April 23, 2007 Share Posted April 23, 2007 Try: <?php $image=mysql_result($godinass,$i,"image"); $imgcheck = $_GET['image']; if(empty($imgcheck)) { $imageurl = "http://mysite.com/images/empty.gif"; }else{ $imageurl = "http://mysite.com/features/".$image; } ?> Link to comment https://forums.phpfreaks.com/topic/48242-solved-check-if-there-is-image-in-db/#findComment-235847 Share on other sites More sharing options...
cheeseus Posted April 23, 2007 Author Share Posted April 23, 2007 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... Link to comment https://forums.phpfreaks.com/topic/48242-solved-check-if-there-is-image-in-db/#findComment-235870 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.