HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


PHP Help

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#36234 (In Topic #8152)
Joe
Avatar

Honoured member

Say if we have a test.php file in a sub-sub-directory under the root, and we tell it to include a file in the actual root. How would I do this?

I've asked this question numerous places, but everyone keeps giving me the same reply, which doesn't work. I've tried:

require_once($_SERVER['HTTP_HOST']."/global.php");
require_once($_SERVER['DOCUMENT_ROOT']."/global.php");
include('./global.php');
include('/global.php');
include('global.php');

…etc.

Back to the top
 
Posted
Rating:
#36235
Joe
Avatar

Honoured member

Also, including URL's doesn't work - I've tried. :(

Back to the top
 
Posted
Rating:
#36236
Joe
Avatar

Honoured member


Back to the top
 
Posted
Rating:
#36240
Avatar

Community saint

This is some thing I have been having trouble with on a mod I am making.

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#36241
Avatar

The official way that usually works…

Code

$script_dir=dirname($_SERVER['SCRIPT_NAME']);

However at ocProducts we've had our script run on so many servers with faulty PHP versions or bizarre configurations, that we've had to take a different approach. Look at what we do in our index.php files.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#36244
Avatar

Community saint

I will try that.
Thanks.

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#36245
Joe
Avatar

Honoured member

I'm still a little confused, mainly because I'm not any good with PHP. Perhaps some detailed information?

Back to the top
 
Posted
Rating:
#36366
Avatar

Community saint

I am not sure how to explain it.

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#36393
Avatar

Community saint

Code

<?php include('file_name.php'); ?>
So, if you had your document root like:

/var/www/htdocs

and you want /var/www/htdocs/include_me.php included with /var/www/htdocs/sub_1/sub_2/some_file.php, then /var/www/htdocs/sub_1/sub_2/some_file.php would contain:

Code

<?php include('../../include_me.php'); ?>
or

Code

<?php include('/var/www/htdocs/include_me.php'); ?>

 

"no violence, no hate, no pain, no enemies
just peace, unity, tolerance and love" - The Beloved

OCP V7 | Advocating monetary reform - FreeOurMoney

Need OCP friendly hosting? Look no further:
Web Hosting, Reseller Hosting, and Dedicated Servers w/cPanel - Elief! - Official hosting partner for ocPortal.
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: