TheLoveableMonty Posted January 28, 2009 Share Posted January 28, 2009 Alright, second query of the day. <meta http-equiv="refresh" content="4"> <?php $location = "curbil.dat"; $file = file_get_contents($location); list($current, $max) = explode(":", $file); $info_location = "inf-bin/bil/$current.dat"; $info = file_get_contents($info_location); list($url, $alt) = explode("||", $info); print "<A HREF=\"$url\" ALT=\"$alt\"><IMG SRC=\"http://www.tenthousandbillboards.com/img-bin/bil/$current.jpg\" HEIGHT=\"400\" WIDTH=\"600\" BORDER=\"0\"></A>"; $fp = fopen($location, "w"); if ($current == $max) { $current = "1:$max"; } elseif ($current > $max) { $current = "1:$max"; } else { $current = ($current+1) . ":$max"; } fwrite($fp, $current); fclose($fp); ?> This is the most basic of basic queries. When $info is false, it prints an error message. What I'd like to do is if $info is false, print an alternative, pre-defined banner and link so there's no broken image. I don't know how to do it though. http://www.tenthousandbillboards.com/demo.php is the script in action. Please excuse the pink image that may load; I asked a friend to whip up a test image while I was at work and he chose to humiliate his brother. Thus, I've just kept using it. The script itself works - Image 7 is the only one I've uploaded files for. It's in the event that something's wrong, I'd like to have a replacement and log the error. I've got the log part sorted though. Link to comment https://forums.phpfreaks.com/topic/142865-solved-false-value-query/ Share on other sites More sharing options...
bluesoul Posted January 28, 2009 Share Posted January 28, 2009 $info_location = "inf-bin/bil/$current.dat"; if(!file_exists($info_location)) { /* display fallback image */ } else { /* do the other stuff */ } Link to comment https://forums.phpfreaks.com/topic/142865-solved-false-value-query/#findComment-748944 Share on other sites More sharing options...
TheLoveableMonty Posted January 28, 2009 Author Share Posted January 28, 2009 Merci Bluesoul. Link to comment https://forums.phpfreaks.com/topic/142865-solved-false-value-query/#findComment-748957 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.