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 trialAndreas Gagnier Ruckert
10,352 PointsNeed help getting ROOT_PATH to work.
I've been trying for a few hours now to figure out my mistake but seem to be no closer, so hopefully one of you guys could help. I have my site located in a subfolder of htdocs called "shirts4mike".
This is the code from my config file:
<?php
define("BASE_URL", "/shirts4mike/");
define("ROOT_PATH", $_SERVER["DOCUMENT_ROOT"] . "/shirts4mike/");
And this is my include:
require_once("../inc/config.php");
Any help would be a lifesaver right now, thanks!
2 Answers
Michael De Marre
14,198 PointsDon't use define(). Change it to $BASE_URL and $ROOT_PATH =
Alexander Stanuga
11,999 PointsAt the moment I can't even view my page, every time I try opening the site in my browser I'm met with a blank white page.
Michael De Marre
14,198 PointsMichael De Marre
14,198 PointsPassing _$SERVER into define is most likely causing your error. The $value property of define() takes only integers, floats, strings, and booleans.
Andreas Gagnier Ruckert
10,352 PointsAndreas Gagnier Ruckert
10,352 PointsThanks so much man, just relieved a major headache. Just out of curiousity though, Randy appears to use a constant instead of a variable in the video, any reason why it might work for him?
Michael De Marre
14,198 PointsMichael De Marre
14,198 PointsRandy is above the law. He does what he pleases.
On a serious note, it might have something to do with the concatenation? Maybe it would have worked if you had surrounded the $value expression with another set of parentheses.
Alexander Stanuga
11,999 PointsAlexander Stanuga
11,999 PointsI've been having a lot of difficulty try ing to resolve this issue, and it appears by the comments/questions at the bottom of the page that I'm not alone.
Just so I understand, regarding the config.php file, what you're suggesting is, instead of...
Which is how Randy showed us to do, we need to replace it with...
is that correct?
If thats the case, my text editor (Coda 2) keeps informing me that:
Parse error: parse error in - on line 3 Errors parsing -
Alexander Stanuga
11,999 PointsAlexander Stanuga
11,999 PointsMy bad, I neglected the $ in order to create the variables. I'll fix that, and I assume that I need to change all the other BASE_URL & ROOT_PATH's on the other documents into variables too?
Alexander Stanuga
11,999 PointsAlexander Stanuga
11,999 PointsHmm still not doing it for me. I'll look elsewhere