Jump to content

Simple IF ELSE error please spot the silly mistake!


Mouse

Recommended Posts

	$mempic = "<img src='images/mugs/'.mug.'_'.$u_uid.'.jpg'>";
      		if (file_exists($mempic)) {
      		} else {
      		$mempic = "<img src='images/...'>";
      		} 

 

tired and on a mission... where am i going wrong here?

http://mouse.nodstrum.com/results2.php?action=wholeResort&resort=dlp this should return two default and two custom images.... but...!

Link to comment
Share on other sites

if (!file_exists($mempic)) {
$mempic = "<img src='images/mugs/mug.'_'.$u_uid.'.jpg' class='picborder' width='47px' height='53px' align='left'>";
} else {
$mempic = "<img src='images/mugs/MugDefault.jpg' alt='No image on file' class='picborder' width='47px' height='53px' align='left'>";
      		} 

 

jesirose, as i understand it the Full code should now be as above... with youe extra "!" in the first line... but this has killed all the images... am i getting your inference right?

Link to comment
Share on other sites

You're messing up your quotes.

if (!file_exists($mempic)) {
$mempic = '<img src="images/mugs/mug_'.$u_uid.'.jpg' class='picborder' width='47px' height='53px' align='left'>";
} else {
$mempic = "<img src='images/mugs/MugDefault.jpg' alt='No image on file' class='picborder' width='47px' height='53px' align='left'>";
}

 

However, as many people mentioned, you can't use file_exists on a url like that, you need to use the path.

Link to comment
Share on other sites

However, as many people mentioned, you can't use file_exists on a url like that, you need to use the path.

 

Ok, at the risk of sounding stupid here... (an ever present risk) what should the code look like bearing in mind here in the UK it is 11.10 pm

 

Many thanks

Link to comment
Share on other sites

Something like this:

 

$mempic = 'images/mugs/mug_'.$u_uid.'.jpg';

if (file_exists($mempic)) {

  $mempic = '<img src="'.$mempic.'" />';

} else {

  $mempic = '<img src="images/mugs/MugDefault.jpg" />';

}

 

If it still doesn't work, try using the FULL path in front of images/ - it will be something like www/domain/html/ etc.

I can't tell your specific one, you have to know it.

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.