Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Some help with 404 errors

    PHP Code:
    if (isset($_GET["id"]))
    {
        
    $id $_GET["id"];
    }

    function 
    main($id) {
        if (
    file_exists($filename "main/$id.php"))
        {
            include 
    "$filename";
        }

    main() is called using the parameter ?id=* and includes a file of the same name. What would be the standard way of me producing a 404 error should $id.php not exist? I don't want to use .htaccess
    I only have a little bit of experience in PHP so if you see something unrelated wrong with my code, let me know

  • #2
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    PHP Code:

    function main($id) {
        if (
    file_exists($filename "main/$id.php"))
        {
            include 
    "$filename";
         } else {
            
    header("HTTP/1.0 404 Not Found");
        }



  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •