SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2002
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Types of paths to use with Includes?

    I have recently installed a IIS server with PHP and have been playing with includes in a project site.

    Every thing is fine until I send my site to the hosting agent (Apache web server) for preview on the internet. I start getting path problems with my includes two layers down from the root folder.

    My question is should I be using absolute paths or relative paths? I would prefer to use relative paths as both my servers have different names.

    My hosting agent has suggested the following:

    <?php include($GLOBALS["DOCUMENT_ROOT"]."$id.inc"); ?>

    This works on the site but errors on the office IIS server.

    Any help would be appreciated

    Kim

  2. #2
    SitePoint Enthusiast numeropi's Avatar
    Join Date
    Apr 2001
    Location
    somewhere between 3.14 and 3.15
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If your host uses Apache, I suggest you do too. It will make life easier for you. If you configure your local system like the real environment the script is going to run in, when you have it running fine on your computer it will most likely work unmodified on the server too.
    No más enlaces rotos en el correo: EnlaceBreve.com
    Tu bitácora en castellano: BitacoraFacil.com

  3. #3
    SitePoint Member
    Join Date
    Feb 2002
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for reply, I agree that would be a good idea. In relation to my question are Absolute or Relative paths the way to go with includes?

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i use relative (as does vBulletin, so it should work fine). say your page is in the site root (e.g. public_html). to include a file in that directory, use:

    PHP Code:
    require('./file.php'); 
    or, a file in the directory above public_html:

    PHP Code:
    require('../file.php'); 
    etc.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


Bookmarks

Posting Permissions

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