PHP relative url - Post ID 887
I use PHP to insert the mast and footer of many of my pages. The way I do this is with a single line of code that looks like this:
<?php include($DOCUMENT_ROOT . "/include/mast.php"); ?>
This has been working well for me until recently. On one of my sites (hosted on Go Daddy), the index.php file is not in the root directory, but is in the single folder that is on the root. That folder is named fbcgcweb, and the index.php file is in that folder.
This is the only site I work with that is on GO Daddy, and I don't know if this is just the way Go Daddy does things, or if the person that originally set the site up did something strange.
My solution to the problem was to use a slightly different code to call the includes: <?php include($DOCUMENT_ROOT . "../include/mast.php"); ?>
I recently added a sub-folder, and now I am guessing that I need to change the code in that sub-folder so it reads: <?php include($DOCUMENT_ROOT . "../../include/mast.php"); ?>
Is there an easier way to do this? Can I just get rid of the fbcgcweb folder and have my index at the root? If so, will I need to have GO DADDY change something that points to the index file?
Maybe I need to find a PHP for Dummies book.
<?php include($DOCUMENT_ROOT . "/include/mast.php"); ?>
This has been working well for me until recently. On one of my sites (hosted on Go Daddy), the index.php file is not in the root directory, but is in the single folder that is on the root. That folder is named fbcgcweb, and the index.php file is in that folder.
This is the only site I work with that is on GO Daddy, and I don't know if this is just the way Go Daddy does things, or if the person that originally set the site up did something strange.
My solution to the problem was to use a slightly different code to call the includes: <?php include($DOCUMENT_ROOT . "../include/mast.php"); ?>
I recently added a sub-folder, and now I am guessing that I need to change the code in that sub-folder so it reads: <?php include($DOCUMENT_ROOT . "../../include/mast.php"); ?>
Is there an easier way to do this? Can I just get rid of the fbcgcweb folder and have my index at the root? If so, will I need to have GO DADDY change something that points to the index file?
Maybe I need to find a PHP for Dummies book.
Is that folder the 'public_html' substitute at GoDaddy? Can't you just try uploading an index file outside that folder, point the php footer and mast to it and see what happens?
I think Bruce uses GoDaddy, maybe he will know.
I think Bruce uses GoDaddy, maybe he will know.
Ha en riktig god dag!
Inger, Norway
My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com
Inger, Norway
My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com
Inger,
Since this is my first use of GoDaddy, I have tried to not mess up things. I will give it a go with putting a page in the root and see what happens.
Since this is my first use of GoDaddy, I have tried to not mess up things. I will give it a go with putting a page in the root and see what happens.
Inger,
I tried to upload to the root directory, and the file aborted with a critical transfer error using Filezilla. Guess that directory has to remain empty, even though there is the fbcgcweb directory that does not show up.
Maybe this is the GoDaddy equivalent of public_html.
I tried to upload to the root directory, and the file aborted with a critical transfer error using Filezilla. Guess that directory has to remain empty, even though there is the fbcgcweb directory that does not show up.
Maybe this is the GoDaddy equivalent of public_html.
Try this..
Dave
<?php include($_SERVER['DOCUMENT_ROOT']."/include/mast.php") ?>
Dave
Let's not get all hurt.
Dave,
I just checked my site, and I have been using this:
<?php include($DOCUMENT_ROOT . "/include/mast.php"); ?>
I will try the format you are suggesting and give it a try.
Thanks.
I just checked my site, and I have been using this:
<?php include($DOCUMENT_ROOT . "/include/mast.php"); ?>
I will try the format you are suggesting and give it a try.
Thanks.
billr wrote:
Dave,
I just checked my site, and I have been using this:
<?php include($DOCUMENT_ROOT . "/include/mast.php"); ?>
I will try the format you are suggesting and give it a try.
Thanks.
Dave,
I just checked my site, and I have been using this:
<?php include($DOCUMENT_ROOT . "/include/mast.php"); ?>
I will try the format you are suggesting and give it a try.
Thanks.
billr,
I'm sorry I didn't reply to you in this thread sooner. The reason it is necessary to use $_SERVER[DOCUMENT_ROOT'] now is because most PHP installs now have register_globals turned off by default therefore rendering the global $DOCUMENT_ROOT useless.
Please see this link for more information.
Dave
Let's not get all hurt.
Dave,
Thanks. I have glanced at that page, and bookmarked it so I can reference it when I have problems.
Thanks. I have glanced at that page, and bookmarked it so I can reference it when I have problems.
Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.