Hi, I am trying to condense my code as much as possible and was trying the following:
<?php
// ************ Section Controls ************
switch ($sec){
// MAIN Sections
default:
$req_file = "news/news.txt";
break;
case "":
$req_file = "news/news.txt";
break;
case "home":
$req_file = "news/news.txt";
break;
case "fof":
$req_file = "fof.php";
break;
// EVENTS Sections
case "upcome":
$req_file = "events/upcomming.php";
break;
case "rslts":
$req_file = "events/results.php";
break;
// SERVERS Sections
case "servers":
$req_file = "servers/serv_info.php";
break;
}
// ************ Error Controls ************
// Check if file exists, else display error page
if (file_exists ('$req_file') {
@require ('$req_file');
} else {
@require ('no_file.php');
}
?>
I also added the file_exists() function in case they request a file that is not available at that time, and plan to build onto this feature late - but at this point it is a basic 404 routine.
Can anyone see why it is not working?
I call this script from the index.php file at the location where I would want the contents of the requested page to be displayed by:
<?php @require ('sections.php'); ?>
😕 Can someone help, please. 😕
Regz,
Charlie