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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    referencing root directories

    I've moved some php files to various sub-directories and now the includes aren't displaying. (ie. I've moved http://xyz.net/company.php to http://xyz.net/company/index.php)

    Using "/" allows images, js files, etc to show, but php includes will not. I'm sure there is an easy fix and I think I may have seen it before, but I've reached an impasse.

    This doesn't work:

    <?php include("/includes/inc.nav.php"); ?>

    This does

    <img src="/art/spacer.gif">

    Ashley

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Scotland
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts
    dead easy - get rid of the initial / when including with php

    <?php include("includes/inc.nav.php"); ?>

    My body's a temple... and like those ancient Greek ones it's a ruin
    sweenster.co.uk

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Root paths do work, but your server root is almost certainly not the same as your domain root - it might be "/home/webs/clients/xyz/public_html" or something.

    You can do this instead:
    PHP Code:
    <?php include($_SERVER["DOCUMENT_ROOT"] . "/includes/nav.inc"); ?>
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    You can do this instead:
    PHP Code:
    <?php include($_SERVER["DOCUMENT_ROOT"] . "/includes/nav.inc"); ?>
    [/B]

    This doesn't work.

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    brothercake used a different file name than you did in his example. You had "inc.nav.php", and brothercake had "nav.inc". Perhaps it is as simple as that... ever check the obvious.
    De gustibus non est disputandum.


  •  

    Posting Permissions

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