SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error including file

    ok
    we have like this
    www/sitefolder
    index page
    left.php
    right.php
    latestcontent.php
    videos.php
    effect.js
    effect.css
    gallery folder
    images folder

    in index.php left and right are included ...
    in right.php there are other pages are included like
    videos.php
    latestcontent.php
    (with js and images...)


    now we have gallery folder
    galleryindex.php

    we are trying to include right.php of root folder in galleryindex.php of gallery folder....
    it brings many problem when we do that
    1)images are not shown
    2)js files and css are not applied....
    (we even tired using absolute path for all but no help..)
    3)if we change path and any how make js work ,the js file of galleryinde.php and js file of right.php collide and one stops working....
    (both tabs..but div id are different..)

    and if we change all the things so that to make right.php work in galleryindex.php inside gallery folder....
    as it is included in the index.php of sitefolder..ie root
    it doesnt works there.....

    so has been great problem to us...

    how can we include the file outside the directory and make it work independently...
    off course it can be done using iframe...or frame
    but with out it....
    using include and require...
    thanks
    please help

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know what is the problem giving the full absolute path on include, images and even all the js? That is the only way of tackling such things. Otherwise make right.php and all the files that are needed inside gallaryindex.php doubles.
    Last edited by Raju Gautam; Sep 14, 2008 at 23:58. Reason: pate=path spelling!
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Addict Sensaay's Avatar
    Join Date
    Feb 2005
    Location
    Scotland
    Posts
    294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    posting the include lines of code might make it easier to spot the problem.
    I'm not an expert which it comes to getting to the right location, but i always use absolute paths to avoid any confusion.

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yeah, use absolute paths in all of your HTML and CSS urls. By absolute I don't mean include the url, I mean put a slash then link to the file from the root.

    For example, if the file is in images/image.jpg, use:
    /images/image.jpg

    That will work in any directory of the site.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For example, if the file is in images/image.jpg, use:
    /images/image.jpg
    Shouldn't that be:

    ../images/image.jpg
    I have always been using '../'.

  6. #6
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No.

    If there is a slash is at the beginning, it goes to the very root.

    For example, say you're at: yoursite.com/somefolder/innerfolder/yetanotherfolder/index.php
    And you want to link to: yoursite.com/images/image.jpg

    You simply use: /images/image.jpg

    This is very useful because you can use the same css file in subdirectories and the images would all be correct.

    '../' simply goes up one folder, so: ../images/image.jpg
    would link to: yoursite.com/somefolder/innerfolder/images/image.jpg
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  7. #7
    SitePoint Addict Sensaay's Avatar
    Join Date
    Feb 2005
    Location
    Scotland
    Posts
    294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ye i always thought ../ went up two folders? and ./ went up one in the structure, if you get what i mean!

  8. #8
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I didn't know that. I was always using ./ and ../...


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
  •