New Posts
Live Radio
Welcome guest, is this your first visit?
  • Login:
PowerPoker.com Affiliate Program
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    PTC
    PTC is offline
    Senior Member
    Sucka-Free Boss
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,140
    Blog Entries
    9
    Feedback Score
    7 (100%)

    Default PHP Include From Subfolders

    EDIT; SOLVED

    I've been putting some include stuff into my sites for navigation lately. The code is working fine for all of the folders in the root directory. The subfolders and lower levels are not working properly.

    I've been adding this to the pages

    HTML Code:
    <?php
    include ('../include/navigation.php');
    ?>

    I have also tried this in hopes of success


    HTML Code:
    <?php
    include ('http://www.myurlhere.com/include/navigation.php');
    ?>

    Here are the warnings I am getting

    HTML Code:
    Warning: include(../include/navigation.php) [function.include]: failed to open stream: No such file or directory in /home/content/03/4610003/html/games/texas-holdem/index.php on line 32
    
    Warning: include() [function.include]: Failed opening '../include/navigation.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/content/03/4610003/html/games/texas-holdem/index.php on line 32
    Would appreciate any help with this. There was a recent thread discussing include stuff and this was appreciated by me, just need a little more help here.
    Last edited by PTC; 08-30-2009 at 12:38 PM.
    "There's something about an underdog that really inspires the unexceptional."
    - Robert California

  2. #2
    CK
    CK is offline
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    ?
    Posts
    2,226
    Blog Entries
    2
    Feedback Score
    35 (100%)

    Default

    If your using dreamweaver you can go to insert > server side include and select the file from the drop down. Then when you create a new page from the existing template it should automatically change the links for you

    <?php require_once('includes/myfilehere.php'); ?>
    An alternative would be this which will avoid you having to change the file path

    <?php include($_SERVER['DOCUMENT_ROOT']."/includes/myfilehere.php"); ?>
    ----------------------------------------
    Everyone says they are willing to do whatever it takes to get ahead - but yet there are so few people up at 5AM ? - Robert Herjavec
    ---------------------------------------

  3. #3
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Jan 2009
    Location
    Northern Europe
    Posts
    882
    Blog Entries
    6
    Feedback Score
    3 (100%)

    Default

    This should be working - maybe you could post your folder structure...

    HTML Code:
    <?php
    include ('../include/navigation.php');
    ?>
    My blog www.unknownwebmaster.com | New posts on Poker affiliate blogs | Webmaster tools I use every day.

  4. #4
    PTC
    PTC is offline
    Senior Member
    Sucka-Free Boss
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,140
    Blog Entries
    9
    Feedback Score
    7 (100%)

    Default

    Quote Originally Posted by Unknown Webmaster View Post
    This should be working - maybe you could post your folder structure...

    HTML Code:
    <?php
    include ('../include/navigation.php');
    ?>

    This is a static site. All pages are on index files inside of their own folders.

    The 2 URLs below work fine
    http://www.mydomain.com/index.php
    http://www.mydomain.com/directory1/index.php

    The folder below returns the warnings
    http://www.mydomain.com/directory2/folder/index.php
    "There's something about an underdog that really inspires the unexceptional."
    - Robert California

  5. #5
    PTC
    PTC is offline
    Senior Member
    Sucka-Free Boss
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,140
    Blog Entries
    9
    Feedback Score
    7 (100%)

    Default

    all I needed was this, thanks everyone

    HTML Code:
    <?php
    include ('../../include/navigation.php');
    ?>
    
    "There's something about an underdog that really inspires the unexceptional."
    - Robert California

  6. #6
    NOT A Moderator
    My Status
     

    Add as a friend
    Join Date
    Dec 2008
    Location
    Canada
    Posts
    1,727
    Feedback Score
    13 (100%)

    Default

    Quote Originally Posted by PTC View Post
    all I needed was this, thanks everyone

    HTML Code:
    <?php
    include ('../../include/navigation.php');
    ?>
    


    While doing that works, it's only a temp fix. If you expand your file structure further, you'll run into the same issue. Always try to use the complete file structure path which usually starts out as /home/[INSERT REMAINDER HERE] and you won't have any other issues even if you change file structure to include more folders in those folders later on.
    Host your sites with a reliable webhost!
    Get quality safe and secure hosting from Garner Hosting.
    Need quality content for your gambling or non-gambling website?
    Now offering translation services! Get Pricing Information

  7. #7
    Formerly TPB
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Wales
    Posts
    666
    Feedback Score
    16 (100%)

    Default

    As Gydian said, if you link to your include file starting with a slash you will be fine. From then on it doesn't matter how many folders down your website goes, as the include will retrieve the file from the correct place. All of my includes start with a slash like this:

    HTML Code:
    <?php
    include ('/include/navigation.php');
    ?>


 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Balancing your anchor text to include Domain
    By Sebastian in forum Poker SEO Forum
    Replies: 2
    Last Post: 02-08-2010, 07:28 AM
  2. Replies: 0
    Last Post: 05-25-2009, 03:40 PM
  3. What would your ideal wordpress theme include?
    By PokerFelts in forum Wordpress - Web Design - Coding - Technical
    Replies: 4
    Last Post: 05-08-2009, 03:06 PM
  4. Wordpress: Include pages in RSS
    By Unknown Webmaster in forum Wordpress - Web Design - Coding - Technical
    Replies: 3
    Last Post: 04-03-2009, 01:58 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
Powered by vBulletin® Version 4.1.5
Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.
SEO by vBSEO 3.6.0
Affiliate Program Consultant