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

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?

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.

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

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.

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.