Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using include() from nested folders

    I'm just going

    PHP Code:
    <? include '/includes/file.php'?>

    but it only works in the root directory. in the next directory I have to go

    PHP Code:
    <? include '../includes/file.php'?>

    Am I missing something here? I thought the preceding / meant start from root, like with images and js includes?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think for root you use ./

    Otherwise, you could just use the complete URL while including:

    include ("http://www.yourhost.com/blahblah/file.php");

    Or I think this works, too:

    include ($DOCUMENT_ROOT."/file.php"); // I saw this in the manual. Better test it.
    Last edited by SYP}{ER; 07-22-2002 at 04:29 PM.
    Offtone.com - In the works...

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for those tips; I didn't wanna use the absolute because I want it to be easily moveable between local and remote servers.

    Your second suggestion also only worked in the root directory, but it sent me along the right lines .. because the next thing i tried worked exactly as i wanted, this:

    PHP Code:
    <? include $HTTP_SERVER_VARS["DOCUMENT_ROOT"] . '/includes/file.php'?>

    cheers
    Last edited by brothercake; 07-22-2002 at 05:24 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
    •