PHP error page

Discussion in 'PHP' started by sebastya, May 27, 2006.

  1. #1
    Hi guyz,

    I want to make it so if a user clicks a broken link, they will be redirected to another area of the site or I can customise the error page, because I don't want them to see this:

    Warning: page(.htm): failed to open stream: No such file or directory in /home/user/public_html/home.php on line 67

    Warning: main(): Failed opening '.htm' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/user/public_html/home.php on line 67

    Anyone know how I can do this?

    Thanks alott in advance.

    -seb
     
    sebastya, May 27, 2006 IP
  2. Shoemoney

    Shoemoney $

    Messages:
    4,474
    Likes Received:
    588
    Best Answers:
    0
    Trophy Points:
    295
    #2
    if ou are using apache check your 404 handler
     
    Shoemoney, May 27, 2006 IP
  3. themole

    themole Peon

    Messages:
    82
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    themole, May 27, 2006 IP
  4. sebastya

    sebastya Well-Known Member

    Messages:
    2,449
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    138
    #4
    Thanks but they didn't work, this isnt a 404/400/500 error thing
     
    sebastya, May 28, 2006 IP
  5. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #5
    put the @ sign before your include or require statement-- that will repress the error

    after that, check to see if the file loaded (assign the file to a variable or see if a variable in that file now exists) .. if it did not load, echo custom error message
     
    TheHoff, May 28, 2006 IP
  6. sebastya

    sebastya Well-Known Member

    Messages:
    2,449
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    138
    #6
    I'm sorry can you please explain with more detail?

    what should my code look like?
     
    sebastya, May 28, 2006 IP
  7. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Wherever you do an include or require, make it look like this

    @include("filename.php");

    Using the @ before a command will prevent the error message from being printed. You don't often want to let your users see an error message.
     
    TheHoff, May 29, 2006 IP
  8. sebastya

    sebastya Well-Known Member

    Messages:
    2,449
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    138
    #8
    Thankss!!!
     
    sebastya, May 29, 2006 IP