Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

New at this, so apologies if I'm not using the correct terminology, but... Locally, in my scripts, I can include scripts using:

include('/include/sample.php');

And it will automatically traverse to my web directory for inclusion... However, when I upload it to my server, it uses the server root at "/".

I don't really know what to search for, otherwise, I'd google, it, but hoping someone knows what I need to change on the server?

share|improve this question
    
You need to consider that an include statement uses file paths, not URLs. The root as the web server sees it is not the same as the file system root. In general it's a bad idea to use absolute paths in PHP, unless you do so using variables, as per Brett's answer. If nothing else, absolute paths break portability. –  John Gardeniers Sep 17 '12 at 23:38

1 Answer 1

Instead of modifying the php.ini you might consider modifying your include. You could use a relative path like:

include('include/sample.php');

or you could use an absolute path like:

include($_SERVER['DOCUMENT_ROOT'].'/include/sample.php');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.