Development Including files with PHP

Discussion in 'Software' started by OneSeventeen, 13 Jan 2004.

  1. OneSeventeen

    OneSeventeen Oooh Shiny!

    Joined:
    3 Apr 2002
    Posts:
    3,454
    Likes Received:
    2
    I can't believe I haven't run into this problem before, but I'm trying to include a file from a previous directory, so here's my file setup:

    root/
    /thesource/
    /inc/
    /term/
    term.php
    db_conn.php
    So term.php is in root/thesource/inc/term/
    and db_conn.php is one directory above it, in root/thesource/inc/

    term.php::
    PHP:
    require("../db_conn.php");
    but, oh no! ../db_conn.php does not exist in /thesource/inc/term/!!
    and neither does ..\db_conn.php

    would the status of allow_url_fopen have an effect? It isn't really a remote site, so I don't see why this won't work.

    This is all being run on a windows server with IIS.
    I'm usually just missing something, but I really don't know what it might be. I'd hate to have to have one massive /inc/ directory without any directories (I like keeping things as neat/organized as possible), but I would be willing if I knew there was no other way.
     
  2. OneSeventeen

    OneSeventeen Oooh Shiny!

    Joined:
    3 Apr 2002
    Posts:
    3,454
    Likes Received:
    2
    I used ini_set("include_path", $inc_folder); to set the default include path to the particular folder for that page, and it worked, but I'd rather not mess with ini settings like that. (I prefer having one standard set instead of odd instances here and there).
     
  3. RTT

    RTT #parp

    Joined:
    12 Mar 2001
    Posts:
    14,120
    Likes Received:
    74
    It's best to do either what you did ;) or just use the /path/to/the/include :)
     
  4. OneSeventeen

    OneSeventeen Oooh Shiny!

    Joined:
    3 Apr 2002
    Posts:
    3,454
    Likes Received:
    2
    I'm not sure if that is also an allow_url_fopen issue or not, but I've never been able to get that to work.

    (We just switched to a new server that is about 15 hours away from here, and we don't have access to it. We had to put in a request for gd2 to be installed and it took about 5 weeks to process.)

    is there a way to allow the /path/to/file/ to work? it works on all my images, just nothing script-related
     
  5. linear

    linear Minimodder

    Joined:
    5 Oct 2001
    Posts:
    4,393
    Likes Received:
    1

Share This Page