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

PHP Enhancing a Simple PHP Application Cleaning URLs with Subfolders Using Absolute Server Paths

Armando Ruiz
Armando Ruiz
8,099 Points

Tryed root relative urls and they did not work. I hust put the '/' before... Why??

Tryed root relative urls and they did not work. I hust put the '/' before... Why??

6 Answers

Is it a typo with "inc/congif.php"? It looks like that is supposed to be "inc/config.php" instead?

Try updating that and see if that solves your issue.

Hi Armando,

It sounds like you did not have the path correctly set. Was the file you were trying to use a relative path for in the same directory?

"./" means same directory and "../" means parent directory

Does that help at all?

Armando Ruiz
Armando Ruiz
8,099 Points

what happens is: I am working in localhost, insede localhost I created a folder na,ed treehouse and I am following the track in that folder. The moment I placed the path, it was wrong, and I tried different paths....

define("BASE_URL","/treehouse/");
define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/treehouse/");

define("BASE_URL","/localhost/treehouse/");
define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/localhost/treehouse/");

Which one I should use??

Armando,

Click on a link and tell us what's in the address bar at the top of the browser. Sometimes just by looking at what the link points to can illustrate why the link fails to work. Maybe there's an extra / or maybe it's just pointing to the wrong location. Let us know what your links are pointing to and we can assist. If you follow the teachings there shouldn't be an issue but you may have just added something you shouldn't have.

Cheers!

Armando Ruiz
Armando Ruiz
8,099 Points

the url: http://localhost/treehouse/

in the browser:

Warning: require_once(inc/congif.php): failed to open stream: No such file or directory in C:\xampp\htdocs\treehouse\index.php on line 3

Fatal error: require_once(): Failed opening required 'inc/congif.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\treehouse\index.php on line 3

Armando Ruiz
Armando Ruiz
8,099 Points

Austin, thanks a lot.... I feel really stupid, because I tried everything!!!! Thanks.

No problem! I've had the same issue many times... it really helps to get some fresh eyes on your code because many times (at least for me) it turns out to be something simple (which is always preferred IMO). Have a great day/night Armando!