Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default PHP Includes help

    Hello, for my site i use PHP Includes but, when you go to the site it displayes my 404 page, but i want it to display my home page, but it wont,

    please help

    my code:

    Code:
    <?php 
    // File include by Blob off of HabboxForum 
    $config = array("default" => "home.php", // Default Page (with trailing .php) 
                    "directory" => "pages/", // Directory where files are held (with trailing slash) 
                    "restricted" => array( "index" ), // Restricted pages 
                    "404" => "404.php" // Error Page (with trailing .php) 
                    ); 
    $page = str_replace("/", "", ( ( ( in_array( $_GET["page"], $config["restricted"] ) ) !== false ) ? "home" : $_GET["page"] ) ); 
    ( file_exists( $config["directory"] . $page . ".php" ) !== false ) ? include( $config["directory"] . $page . ".php" ) : include( $config["directory"] . $config["404"] );  
    ?>
    you can view it in action at

    http://www.dfiles.co.cc/site

  2. #2
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Default

    Try this buddy:

    <?php
    // File include by Blob off of HabboxForum
    $config = array("default" => "home.php", // Default Page (with trailing .php)
    "directory" => "/site/", // Directory where files are held (with trailing slash)
    "restricted" => array( "index" ), // Restricted pages
    "404" => "404.php" // Error Page (with trailing .php)
    );
    $page = str_replace("/", "", ( ( ( in_array( $_GET["page"], $config["restricted"] ) ) !== false ) ? "home" : $_GET["page"] ) );
    ( file_exists( $config["directory"] . $page . ".php" ) !== false ) ? include( $config["directory"] . $page . ".php" ) : include( $config["directory"] . $config["404"] );
    ?>
    Last edited by ThisNameWillDo!; 15-09-2009 at 02:57 PM.
    Free Online Games And Videos:
    http://www.vincesgames.com



  3. #3
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    everything else works fine, its not the folder locations

  4. #4
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Default

    Quote Originally Posted by 2fast2kwl View Post
    everything else works fine, its not the folder locations
    I believe it is, as currently you have the directory as /pages/, yet you do not even have a pages folder. Just try mine and tell me if it works, it should do.
    Free Online Games And Videos:
    http://www.vincesgames.com



  5. #5
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    i do have a pages folder, all of the pages are in it...

    EDIT:

    tried yours got this:


    Warning: include(/site/404.php) [function.include]: failed to open stream: No such file or directory in /home/dfilesco/public_html/site/index.php on line 38

    Warning: include() [function.include]: Failed opening '/site/404.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/dfilesco/public_html/site/index.php on line 38

  6. #6
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Default

    Strange, it wasn't showing up that you did earlier, yet now it's showing up.
    Free Online Games And Videos:
    http://www.vincesgames.com



  7. #7
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Default

    Quote Originally Posted by 2fast2kwl View Post
    i do have a pages folder, all of the pages are in it...

    EDIT:

    tried yours got this:


    Warning: include(/site/404.php) [function.include]: failed to open stream: No such file or directory in /home/dfilesco/public_html/site/index.php on line 38

    Warning: include() [function.include]: Failed opening '/site/404.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/dfilesco/public_html/site/index.php on line 38
    It is showing this error because your 404.php file is not in the /site/ folder, if you moved that to there then it would probably work.
    Free Online Games And Videos:
    http://www.vincesgames.com



  8. #8
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    my 404 is in the site folder, www.dfiles.co.cc/site/404.php

    weird, all my pages are in it and always have been.

    been a bit weird recenlty like my 404 disapering then reapearing

  9. #9
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Default

    Yes, your /pages/ folder disappeared on me just now, yet now it is showing again. I don't understand.

    The requested URL /site/404.php was not found on this server.
    Free Online Games And Videos:
    http://www.vincesgames.com



  10. #10
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    try again

Page 1 of 2 12 LastLast

Posting Permissions

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