cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 I had a nice function that loaded a blank image if someone monkeyed around with the url for my image gallery viewer: <?php $image = "http://www.upperstraitscleanlake.org/Gallery/".$imgsource; if (!is_readable($image)) { $image = "http://www.upperstraitscleanlake.org/Gallery/images/noimage.jpg"; } ?> you can see it at: http://upperstraitscleanlake.org/Gallery/imgview.php?type=nature&img=1 now it fails on all images, but if you not the image you see at the top its source is $image (before entering the if logic) and now the function is always saying yes $image is not readable Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 if (!is_readable($image)) { $image = "http://www.upperstraitscleanlake.org/Gallery/images/noimage.jpg"; } that condition is true if the image is not readable see the ! or i was wrong Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Author Share Posted June 27, 2007 yes that is right. If the file can't be read then it changes $image to a default. However its failing on images that are clearly images because I can echo <img src=$image> and the image is viewable. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 $image = "http://www.upperstraitscleanlake.org/Gallery/".$imgsource; $image = "http://www.upperstraitscleanlake.org/Gallery/images/noimage.jpg"; see ^^ images is missing i guess or can see the $imgsource declaration Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Author Share Posted June 27, 2007 did you view the page? The first img and text is the pre entering the if the second is post the if statement Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Author Share Posted June 27, 2007 Solved it! Removed the absolute path and changed it to a non-absolute path and it fixed it. My host must not like the absolute part although it don't explain why it worked an hour ago and now it don't 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.