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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    May 2008
    Location
    Missouri
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post

    Unhappy Please help, stupid here

    Very new to php, this is not on line to see yet so will try to explain, should be simple but not understanding it.

    Ok I have in short dir tree:
    Main level under which is, (plus others but this is the concern ones)

    img
    include
    recipes

    none of the links below will work, just posted so you can see what I am saying

    One the root level there is a recipe.php this file opens up a directory to the dir recipes.

    In the recipe dir are a bunch of wine recipes lets use a example say peach_fizz.php.

    The main recipes.php opens and looks fine, when you click on that page peach_fizz.php it opens but all the images use a directory structure as http://localhost/honey001/recipes/img/image.php where it should be http://localhost/honey001/img/image.php.

    Easy fix there I just added /img/ to the recipes dir. (not right I do not think but fixed it)

    Now the problem is when you are at the http://localhost/honey001/recipes/peach_fizz.php page ALL links are now http://localhost/honey001/recipes/recipe.php when it should be http://localhost/honey001/recipe.php it adds the recipes dir 2 times.

    How do I fix this?? I am assuming some type of config file for dir structure but do not know how or where or what to add please help!

  2. Users who have thanked bmccune for this post:

    NightFlyer (05-18-2008)

  • #2
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    either fully qualify the url that your links are pointing to eg.
    http://localhost/honey001/recipe.php
    or use relative pathing to step back a level
    ../recipe.php

    if you want to fully qualify the path, but you don't want the headache of going through and replacing all the references to localhost after you deploy your site to the internet (unless you never do plan to deploy to anything other than the computer you're developing on), you can modify your hosts file to trick your computer into thinking that the web site you're creating is on the name that it would be running on. i'm sure there are some good posts running around on here about that.
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    you could make all your links relative - not to the actual script being run but - to the root of your web dirs.

    so a href="honey001/blah" could become href="/honey001/blah"

    As mjlorbet suggests, you really do want to make them portable so that they will work if your move the site onto your server.


    Edit:
    How do you thank some one for posting a question? Isn't thast the whole point of CF?



    bazz
    Last edited by bazz; 05-18-2008 at 01:14 PM.

  • #4
    New to the CF scene
    Join Date
    May 2008
    Location
    Missouri
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post

    Please re read, miss understanding concern, my fault.

    Quote Originally Posted by bazz View Post
    you could make all your links relative - not to the actual script being run but - to the root of your web dirs.

    so a href="honey001/blah" could become href="/honey001/blah"

    As mjlorbet suggests, you really do want to make them portable so that they will work if your move the site onto your server.

    bazz
    Well this was my fault, thanks for responses but think your misunderstanding...

    The dir structure again is as follows:
    Main level under which is, (plus others but this is the concern ones)

    img
    include
    recipes

    Under the include dir I have rightside.php, left_side.php, header.php, footer.php.

    In the main root I have all the files for the site of course and under recipes I have all the recipe files. So when I click on recipes.php (in main root) it opens, all good. Then when I click on a recipe in this file it opens in the /recipes dir. Now that file being in a different dir but using the same includes dir as all now shows all the links as coming from /recipes/recipes.php which the recipes.php is in the /root dir not /recipes dir.

    I am using the same /include dir for all which is the problem but I do not know how to walk around not having 2 /include dir's or 2 /img dirs. I figure it must be in some kind of config.php or something of which I do not have nor know how to implement correctly.

    Hope that clears it up a bit...

    Thanks in advance.
    Ben

  • #5
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Doesn't clear it up for me.

    does your root directory have a file called recipe.php?

    when viewing it, does it include another file to show the recipes or does it actually show the recipes? I don't know.

    if the file to show a recipe is in the root dir then you can link to it with the href like this

    Code:
    href="/recipe.php"></a>
    that will look for a file called recipe.php in the root dir.

    bazz

  • #6
    New to the CF scene
    Join Date
    May 2008
    Location
    Missouri
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by bazz View Post
    Doesn't clear it up for me.

    does your root directory have a file called recipe.php?

    when viewing it, does it include another file to show the recipes or does it actually show the recipes? I don't know.

    if the file to show a recipe is in the root dir then you can link to it with the href like this

    Code:
    href="/recipe.php"></a>
    that will look for a file called recipe.php in the root dir.

    bazz
    Yes recipes.php IS in the root and shows ALL the recipe php files BUT the recipes themselves are in a dir called /recipes

    Example here is the total structure of the dirs;

    -honey001 (under root dir) index.php, aboutus.php, recipes.php etc etc etc.
    ---cgi-bin
    ---banners
    ---contact
    ---directory
    ---img
    -----(under img dir) all jpg's and gif files
    ---include
    -----(under include dir) header.php, footer.php, rightside.php, leftside.php
    ---recipes
    -----(under recipe dir) cherry.php, apple.php, peach.php etc etc etc.

    Again lilnks are just for visual, do not work.

    So when you go to http://honeycreek.us/ it pulls up the index.php. When you there if you click recipes.php it pulls it up as it IS IN the root dir, all good.

    Now when your on recipes.php and click a recipe say apple it now changes the dir and goes to /recipe/apple.php. Now while your on apple.php under the /recipes dir now all links including the img links do not work properly as the file THINKS all is suppose to be as follows:

    recipe/recipe/cgi-bin
    recipe/banners
    recipe/contact
    recipe/directory
    recipe/include/ header.php, footer.php, rightside.php, leftside.php
    recipe/img/ all jpg's and gif files

    See it ADDS the recipe dir to all the dirs instead of going back to root. I know it is simple but not sure how to do w/o making double's of everything. It is a simple re direct I think just not sure.

  • #7
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    lol, we are both confused. Maybe we've had to much apple cider!!

    I have looked at your siote and I don't get any php pages. Followed your instructions and every page seemed to be .htm.

    I didn't notice anything, on any page, not working.

    bazz

  • #8
    New to the CF scene
    Join Date
    May 2008
    Location
    Missouri
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by bazz View Post
    lol, we are both confused. Maybe we've had to much apple cider!!

    I have looked at your siote and I don't get any php pages. Followed your instructions and every page seemed to be .htm.

    I didn't notice anything, on any page, not working.

    bazz
    Well you did not read fully the links as said ARE VISUAL as ALL is still on my pc not at the site.... Yes all at the site are in htm I am changing all to php but as said NOT up yet.....

    I fixed it anyway. Am sure it was not the easiest way but IF I added the includes dir under the recipe dir then edit the path in that folder all works fine. Now I have 2 include dirs, one on the rott and the other under recipes for it to work, I know there is a better way......

    I would think something like a config.php or settings.php that is included in say the header.php off of the root/include dir with some code in it to point to correct dirs. A path instance or something. That is what I am needing and do not know how to do it to eliminate the need for the other include dir.

    Now to make all work my structure is:

    root or localhost
    all main files here
    --img
    --include
    -----(under includes, leftside.php, rightside.php, header.php,footer.php)
    --cgi-bin
    --recipes
    --all wine recipes are under here
    ------(under recipes now)
    ------img
    ------include (leftside.php, rightside.php, header.php,footer.php same as above in the root folder to make it work properly)

    It works bby doing it this way just does not seem correct...


  •  

    Posting Permissions

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