akreation Posted December 17, 2006 Share Posted December 17, 2006 How do I replace, or use a different "image unavailable" file when the image is unavailable?Example::If image1.jpg is unavailable the use image2.jpgThe code below is the image that is unavailable sometimes, because all records do not have images.[code]<img src="/scripts/phpThumb/phpThumb.php?src=/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>2.jpg&w=150&h=150" border="0">[/code]Hope this is clear enough, thanks in advance, and forgive the newbe. Quote Link to comment Share on other sites More sharing options...
Orio Posted December 17, 2006 Share Posted December 17, 2006 What do you mean by unavailable? That it doesnt exist?Orio. Quote Link to comment Share on other sites More sharing options...
zq29 Posted December 17, 2006 Share Posted December 17, 2006 [code]<?php$path = "path/to/your/images/test.png";$path = (file_exists($path)) ? $path : "path/to/your/images/no_image.png";echo "<img src='$path' alt='My Image' />";?>[/code] Quote Link to comment Share on other sites More sharing options...
akreation Posted December 17, 2006 Author Share Posted December 17, 2006 Thanks SA, thats what i need, just haing a little trouble with my code. I tried the ones below with no luck. [code]<?php$path = "/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>1.jpg";$path = (file_exists($path)) ? $path : "/images/whowont_logo.jpg";echo "<img src='$path' alt='My Image' />";?>[/code][code]<a href="/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>1.jpg"><img src="<?php $path = "/scripts/phpThumb/phpThumb.php?src=/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>1.jpg&w=150&h=150";$path = (file_exists($path)) ? $path : "/images/whowont_logo.jpg";echo "<img src='$path' alt='Legendary Place Image One' />";?></a>[/code] Quote Link to comment Share on other sites More sharing options...
matto Posted December 17, 2006 Share Posted December 17, 2006 You should really use is_file() instead of file_exists() to test if the 'file' exists - file_exists() will return true on directories..... ;) 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.