HabboxWiki needs you!
Are you a Habbo buff? Or maybe a rare trader with a bunch of LTDs? Get involved with HabboxWiki to share your knowledge!
Join our team!
Whether you're raving for rares, excited for events or happy helping, there's something for you! Click here to apply
Need a helping hand?
Check out our guides for all things to help you make friends, make rooms, and make money!


Results 1 to 8 of 8
  1. #1
    Join Date
    May 2005
    Location
    united kingdom
    Posts
    8,084
    Tokens
    595

    Latest Awards:

    Default PHP Includes not working? +REP!

    Hi guys...

    Sorry for the rush, but I'm going just now, under Web Tutorials, there's a thread about php includes instead of iframes...

    I am using this, and it seems that they dont change when I link... it stays at the default...

    Links are:

    index.php?page=web or w.e

    Thankssss....

    drink up this bottle of yeah
    and P A I N T your body on me


  2. #2
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    Helps to post the code in question. IE; the code you have, not what the tutorial gave y ou.

  3. #3
    Join Date
    May 2005
    Location
    united kingdom
    Posts
    8,084
    Tokens
    595

    Latest Awards:

    Default

    Well, I decided in the end to try this code:
    Code:
    <?php 
    if (!isset($page)) 
    { 
    include("pages/main.php"); 
    }  
    if(file_exists($_GET['page'].".php")){ 
        include $_GET['page'].'.php';     
    } 
    if(file_exists($_GET['page'].".html")){ 
        include $_GET['page'].'.html'; 
    } 
    if(file_exists($_GET['page'].".txt")){ 
        include $_GET['page'].'.txt'; 
    } 
    elseif (isset($page) && !@include("$page")) 
                 { 
                 echo "Error Page not found!"; 
         }  
    ?>

    drink up this bottle of yeah
    and P A I N T your body on me


  4. #4

    Default

    All your includes are missing some kind of text string:

    Code:
    include "$_GET['page'].'.txt'"
    Not sure if that's necessary but I usually use ' or ".

  5. #5
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by Myke View Post
    Well, I decided in the end to try this code:
    Code:
    <?php 
    if (!isset($page)) 
    { 
    include("pages/main.php"); 
    }  
    if(file_exists($_GET['page'].".php")){ 
        include $_GET['page'].'.php';     
    } 
    if(file_exists($_GET['page'].".html")){ 
        include $_GET['page'].'.html'; 
    } 
    if(file_exists($_GET['page'].".txt")){ 
        include $_GET['page'].'.txt'; 
    } 
    elseif (isset($page) && !@include("$page")) 
                 { 
                 echo "Error Page not found!"; 
         }  
    ?>
    Change all instances of $page to $_GET['page'].

  6. #6
    Join Date
    May 2005
    Location
    united kingdom
    Posts
    8,084
    Tokens
    595

    Latest Awards:

    Default

    Nope, that didn't work

    drink up this bottle of yeah
    and P A I N T your body on me


  7. #7
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    PHP Code:
    <?php

    //variables
    $pageRequest htmlentities$_GET['page'] );
    $pageDefault 'home';
    $pageExtension '.html';
    $pagesPath 'includes/pages/';

    //completed request
    $pageInclude $pagesPath $pageRequest $pageExtension;

    //set default page if none is set
    if( $requestedPage == '' $requestedPage $defaultPage;

    //check if selected page exists
    if( file_exists$pageInclude ) ) {
        include 
    $pageInclude;
    } else {
        echo 
    "Page not found. Try again, or go back.";    
    }

    ?>
    Wrote that really quickly, tried to make it simple to edit. Hope it works/helps.

  8. #8

    Default

    Strange. Try this:



    It works on my hosting:
    http://habtown.net/test.php?page=fail
    With



    Edit: Fail is contained within the /pages/ folder.
    Last edited by Jam-ez; 20-05-2009 at 03:06 PM.

Posting Permissions

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