SitePoint Sponsor

User Tag List

Results 1 to 25 of 25
  1. #1
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    About error pages...

    I am using a index.php?page=lala kind of layout for my site navigation. Whenever a link points to a page that is missing through index.php?page=
    I just get a php warning:
    Warning: Failed opening 'strategies.php' for inclusion (include_path='') in c:\apache\www\index.php on line 96
    How would I get my custom error page to show up instead of this error? My site is www.neofrontier.com, click on BD Strategies for a test run of the error.

    Also, I have been wondering, how do I get php, or whatever language would be better, to inform me of a missing page? I know that you can have them automatically informed to you, or you can have the user click a "report missing page" button on the missing page. How would I do that??
    Content Writing Service - Get custom SEO articles for 10$

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For your second point I've seen some site use this for the user to report back the error page, time, browser in use etc etc

    Also other sites use this page for sitemaps, searchs etc. What you need to do is read up on setting up this kind of page - usually a 404.

    There is an article on this over at www.devarticles.com for the Apache web server - I assume you're using this ?

    Also there is something about this at www.alistapart.com - do a search there, or try www.phpbuilder.com and www.devshed.com 8)

    As to your first point, have a look at the manual for error reporting - you can write your own script(s) to generate 'clean' errors, log them etc - for example if an INCLUDE file fails 8)

  3. #3
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $page $_GET['page'];
    if (!
    $page)
    {
      
    header("error.php");
    }
    else
    {} 
    try that.

    -rsdl

  4. #4
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes yes, I know that you CAN do that... And I have a custom 404 error page on my site, but for some reason, it doesn't load for the missing pages called through index.php?page=

    And yet I still don't know how to do it... How do you DO the error reporting? Because i've seen it many times before...
    Content Writing Service - Get custom SEO articles for 10$

  5. #5
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, didn't see the new post before posting my reply ...
    Content Writing Service - Get custom SEO articles for 10$

  6. #6
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And I would add that code into where?
    Would the code then look like this:
    PHP Code:
    <?php
    $file 
    = ( isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : 'default' );
    include(
    $file '.php');
    $page $_GET['page']; 
    if (!
    $page

      
    header("error.php" ); 

    else 
    {} 
    ?>
    Content Writing Service - Get custom SEO articles for 10$

  7. #7
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Uhh... Why is this:
    PHP Code:
    <?php
    $file 
    = ( isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : 'default' );
    $page $_GET['page']; ?>
    <?php
    if (!$page

      include(
    'missing.htm'); 

    else 
    {
    include(
    $file '.php');

    ?>
    displaying ONLY the missing.htm page on EVERY page?
    Content Writing Service - Get custom SEO articles for 10$

  8. #8
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe because $page is empty. echo $page to see if there's anything in it.

    -rsdl

  9. #9
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean?
    How would I echo $page ?
    What is $page supposed to contain???
    Content Writing Service - Get custom SEO articles for 10$

  10. #10
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $page $_GET['page']; ?> 
    that's a snippet from the code you posted. $page is supposed to contain the variable that you passed via get (e.g. www.blah.com?page=somepage)

    what you've done is if $page is empty, then load missing.htm. that's why you keep getting that page.

    -rsdl

  11. #11
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still confused. Seems right. I'm not good at php. Could you fix it some how please?
    Content Writing Service - Get custom SEO articles for 10$

  12. #12
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah, i see what you're tyring to do. get rid of $page = $_GET['page']; . and change $page in the if statement to $file.

    -rsdl

  13. #13
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, that kinda worked, but now the missing.htm page isn't loading for the 404 (Once again...)
    Content Writing Service - Get custom SEO articles for 10$

  14. #14
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $file = ( isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : 'default' );

    this line says that if $HTTP_GET_VARS['page'] is empty, then replace it with 'default'.

    if you want the 404 to load when $HTTP_GET_VARS['page'] is empty (note: $HTTP_GET_VARS is the same as $_GET). Then get rid of that line and replace it with
    $file = $_GET['page'];

    i hope this solves your problem

    -rsdl

  15. #15
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But you don't understand. When it is empty, I need it to display my default page that contains the contents for the main page. While as I need a 404 to display whenever the page doesn't EXIST... So confusing...
    Content Writing Service - Get custom SEO articles for 10$

  16. #16
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah. well that's not a php problem then. it's a .htaccess question.

    -rsdl

  17. #17
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ... Ok, can anyone ELSE help me?
    Content Writing Service - Get custom SEO articles for 10$

  18. #18
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, don't want to be mean, but, I have plainly stated that I already have a 404 error page. Give it a try at: http://www.neofrontier.com/lalala
    But, I can't get it to work with missing pages called through index.php?page=

    How many times will I have to retype that??? Or can this truly BE fixed through .htaccess.

    You know, it would help A LOT and save us a bunch of time if we just posted the answers with the correct solutions right away. Could you please do that? Or do you not know how to
    Content Writing Service - Get custom SEO articles for 10$

  19. #19
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what server are you using?

  20. #20
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit:

    didn't see your new post

  21. #21
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit:

    didn't see yours either
    :P sorry
    Content Writing Service - Get custom SEO articles for 10$

  22. #22
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where Are All The Php Gurus!?
    Content Writing Service - Get custom SEO articles for 10$

  23. #23
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using Apache 1.3.27
    Content Writing Service - Get custom SEO articles for 10$

  24. #24
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i think i got it.
    PHP Code:
    $file = ( isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : 'default' );

    $file .= ".php";

    // loads $file, does not output anything if $file does not exist
    $check = @include($file);

    // if $check is empty, meaning the file does not exist, then load missing.htm
    if (!$check)
    {
      include(
    'missing.htm'); 
    }
    else
    {} 

    i hope this works this time
    i tested it here
    http://exchange.digitalfoundry.ca/te...?page=test.php
    http://exchange.digitalfoundry.ca/test1.php?page=alalla

    -rsdl

  25. #25
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Amazing! It works! Thank you so much friend!
    Content Writing Service - Get custom SEO articles for 10$


Bookmarks

Posting Permissions

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