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
Rossouw Strydom
12,398 PointsServer Paths and Constants code challege 3/3
hi all
I'm not sure what to do can someone help me?
The name of the owner of the company is in a variable called “owner”. Replace the question marks in the code below with the owner’s name. (Be sure to leave the space between the colon and the name intact, along with all the other HTML.)
<p><strong>Owner:</strong> <?php echo $owner?></p>
<p><a href="/contact/">Contact</a></p>
<?php include($_SERVER["DOCUMENT_ROOT"] . "../../config/company.php");
19 Answers
Kevin Korte
28,149 PointsYou're going to have to use concatenation to concatenate the space and the variable $owner. This space you put between the strong tag and the php echo statement will just be ignored by the browser.
To echo a space to the browser, we need to put it in parenthesis, like so: " " And the concatenation operator is a period: like so: .
So in your echo statement, you need a space, concatenated to the variable $owner.
You also need to put a colon at the end of your variable, so php knows thats the end of that line.
And finally, the name that the variable $owner holds is assigned in the company.php file you have included. However, you are including the file after you use the variable. So when php executes your code, the variable $owner has no value. You need to move your include statement to the very top of your document, before any HTML mark up.
And one final thing. It tells you to include that file using relative URLs. Using $_SERVER["DOCUMENT_ROOT"] is a way to link files using absolute links. You are combining absolute links with relative links. You include process has this logic.
We know the file lives in this structure: root/config/company.php
1)Go to server root folder, go back two directories outside of root... 2)Look for a file called config -(it won't find it)
So it can't find the file that holds the value of the variable $owner
So if you fix all of that, you should be good!
Rossouw Strydom
12,398 PointsThanks for the help. hopefully ill get it right. :)
Kevin Korte
28,149 PointsLet us know! Otherwise we can break it down even more for ya! Didn't want to give you much of a hint just yet! :)
Rossouw Strydom
12,398 PointsThanks! I appreciate the help.
Rossouw Strydom
12,398 PointsI got so far, but now om not sure
<?phpinclude("../../config/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>
Kevin Korte
28,149 PointsOk, So your file include is correct, except I'd put a space in between the php tag and the include. That likely will cause an error. So:
<?php
include("../../config/company.php");
?>
So, what do we know? We know that the name of the owner is now stored in a variable called $owner. And we need to remove the questions marks, and it's place, put our variable $owner in an echo statement. It reminds to to leave a space between the colon and the name, so we know we are going to need to use the concatenation operator which is a period, to concatenate a space and the variable $owner. A space in a set of parenthesis with a space in between them.
So you're going to be writing a inside of opening and closing PHP tags, an echo statement, a space, a concatenation operator, and our variable $owner.
Try that before I give any more.
Rossouw Strydom
12,398 PointsThat pass I am at 3/3 now. So far i have and it display the name but something slightly wrong.
<?php echo "" . $owner; ?>
Kevin Korte
28,149 PointsYour parenthesis are empty. put a space between them. One space bar. LIke so -> " "
Rossouw Strydom
12,398 Pointslike this?
<?php echo " ". $owner; ?>
Kevin Korte
28,149 PointsYep. That code should pass you.
Rossouw Strydom
12,398 PointsIt don't want to. :(
<?php include("../../config/company.php"); ?> <html> <head> <title>Leadership | Shirts 4 Mike</title> </head> <body>
<h1>Leadership</h1>
<p><strong>Owner:</strong>
<?php
echo " " . "$owner";
?>
</p>
<p><a href="/contact/">Contact</a></p>
</body> </html>
Kevin Korte
28,149 PointsYou placed quotes around the variable $owner in the above code. Quotes are only for strings. When using a variable, you do not use quotes, so remove those.
Rossouw Strydom
12,398 Pointsi left out the parenthesis of owner also
Rossouw Strydom
12,398 Points<?php include("../../config/company.php"); ?> <html> <head> <title>Leadership | Shirts 4 Mike</title> </head> <body>
<h1>Leadership</h1>
<p><strong>Owner:</strong>
<?php
echo " " . $owner;
?>
</p>
<p><a href="/contact/">Contact</a></p>
</body> </html>
Rossouw Strydom
12,398 PointsIt still don't work :(
Kevin Korte
28,149 PointsI copied and pasted your code from above, removed the parenthesis around $owner and it passed me.
Just to double check, cause it should work:
<p><strong>Owner:</strong><?php echo " " . $owner; ?></p>
Rossouw Strydom
12,398 PointsThanks now it pass maybe a space or something. Thanks a lot for the help Kevin. appreciate the help.
Kevin Korte
28,149 PointsNow problem, good to hear! You were there, I'm not sure what the issue was, cause like I said your code worked for me before I posted that code back.
Good job and good luck!
Nick Davies
7,972 PointsI found leaving no space between the quotes worked for me. Like this: <?PHP echo "". $owner; ?>