Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

John Glynn
8,239 PointsServer paths and constraints challenge 2/3
Can someone tell me what I'm doing wrong? I've tried a bunch of different combinations and can't seem to get this to work...
The question: There is a file located at htdocs/config/company.php on the server. We need to include that file to get access to some of information about the company. At the very top of the file below, before any of the HTML, include that company.php file using a relative server path.
My code: <?php include("/company.php"); ?>
<html> <head> <title>Leadership | Shirts 4 Mike</title> </head> <body>
<h1>Leadership</h1>
<p><strong>Owner:</strong> ????</p>
<p><a href="/contact/">Contact</a></p>
</body> </html>
4 Answers

John Glynn
8,239 PointsThis ended up working for me but I don't really understand why. I thought $_SERVER["DOCUMENT_ROOT"] ...starts from the root. Why did I need to then go back two directories?
<?php include($_SERVER["DOCUMENT_ROOT"] . "../../config/company.php"); ?>

Rossouw Strydom
12,398 PointsHey can someone help me with this code challenge 3/3, I don't understand it?
Chris Lovelace
2,289 PointsYou will need to echo php code into the page.
<?php echo $owner ?>
Juliano Vargas
Courses Plus Student 15,575 PointsI don't understand that here i my code <?php include $_SERVER['DOCUMENT_ROOT'] . '/company.php'; ?>
<html> <head> <title>Leadership | Shirts 4 Mike</title> </head> <body>
<h1>Leadership</h1>
<p><strong>Owner:</strong> ????</p>
<p><a href="/contact/">Contact</a></p>
</body> </html>
it says that i am including the file correctly but it does not pass it asks me to try again. anyone knows why and what I could be missing?

Brian Knopke
Courses Plus Student 1,905 PointsI think it's because you need to go up two levels of directory.
../ = up one directory (added twice in correct code)
Since the file you are working on is root_directory/about/leadership/index.php
You start in the leadership directory
Up one directory takes you to /about/
Up one more directory takes you to the root directory
now that you are in the root directory you can add the file path
<?php include_once('../../config/company.php'); ?> or <?php include($_SERVER["DOCUMENT_ROOT"] . "../../config/company.php"); ?>

Brian Knopke
Courses Plus Student 1,905 PointsI believe the reason you need to go back 2 directories is because they are asking for a relative server path not a root-relative server path.
I would love some feedback from the staff.

Ismail Qaznili
27,996 PointsTrue, the last segment of the question states "using a relative server path" which is " ../ ' prefix. (took me a while to noticed since I think everyone -me included - is focusing on using the best common practice "root-relative server path")
Jack Vliegendhart
6,581 PointsJack Vliegendhart
6,581 PointsYeah, would like to know this as well.
Also this gets validated as correct as well:
<?php include_once('../../config/company.php'); ?>
and this doesn't work:
<?php include_once('../htdocs/config/company.php'); ?>
strange...