Mouse Posted February 9, 2007 Share Posted February 9, 2007 $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...! Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 '.mug.' mug isn't a variable here, nor a string. Change your if to: if (!file_exists($mempic)) { $mempic = "<img src='images/...'>"; } Quote Link to comment Share on other sites More sharing options...
ikmyer Posted February 9, 2007 Share Posted February 9, 2007 i think you are not checking the file_exist() on a valid format... should their be $mug in the first line ? Also seems your ' and " are not consistant Quote Link to comment Share on other sites More sharing options...
emehrkay Posted February 9, 2007 Share Posted February 9, 2007 files_exist checks against a file, not html code so in short, check against the src of the img Quote Link to comment Share on other sites More sharing options...
Mouse Posted February 9, 2007 Author Share Posted February 9, 2007 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? Quote Link to comment Share on other sites More sharing options...
ikmyer Posted February 9, 2007 Share Posted February 9, 2007 , it would be... images/mugs/'.$mug.'_'.$u_uid.'.jpg for the file_exist() Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 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. Quote Link to comment Share on other sites More sharing options...
Mouse Posted February 9, 2007 Author Share Posted February 9, 2007 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 Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 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. Quote Link to comment Share on other sites More sharing options...
Mouse Posted February 9, 2007 Author Share Posted February 9, 2007 many thanks... i'm off to play with the options! Night All Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.