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
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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.