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 4 of 4
  1. #1
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,008
    Thanks
    59
    Thanked 10 Times in 10 Posts

    Question If the page doesn't exist I get an error

    Hi coders, long time no see!

    Ok heres my problem:

    I use this to pull in content

    if( isset($_GET['page'])){
    include('pages/'.$_GET['page'].'.php') ;

    }

    However if the page doesn't exist I get an error. What is the best way to check for this?


  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,151
    Thanks
    2
    Thanked 335 Times in 327 Posts
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by nikos101 View Post
    Hi coders, long time no see!

    Ok heres my problem:

    I use this to pull in content

    if( isset($_GET['page'])){
    include('pages/'.$_GET['page'].'.php') ;

    }

    However if the page doesn't exist I get an error. What is the best way to check for this?
    use file_exists to check if a file with this name exists.

    http://www.php.net/manual/en/function.file-exists.php

    also read the note about symlinks.

    best regards

  • #4
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,008
    Thanks
    59
    Thanked 10 Times in 10 Posts
    thanks coders that worked a treat



  •  

    Posting Permissions

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