I implemented a simple php scrpit that shows a random line of text on my webpage from the file qsdatabase.php. <?php $quotes = file("random/qsdatabase.php"); $quote = rand(0, sizeof($quotes)-1); echo $quotes[$quote]; ?> From time to time it gives a error it can't find the file qsdatabase.php on the server. And it displays that message on the screen which I just can't have I'm kind of new to php. Can someone please show me how to make a fail safe or something. Like if it does not find the file to display another pre-set message or just don't display anyhing.
I think you can use this if(file_exists('random/qsdababase.php')!=FALSE) { $quotes = file("random/qsdatabase.php"); $quote = rand(0, sizeof($quotes)-1); echo $quotes[$quote]; } PHP: