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 Using PHP with MySQL Querying the Database with PHP Avoiding Duplication

ROOT_PATH . NOT WORKING

using this code require(ROOT_PATH . "inc/connect_to_db.php"); gives me errors. If I exclude the "ROOT_PATH" it works just fine.

The error I get is: Use of undefined constant ROOT_PATH - assumed 'ROOT_PATH' in C:\wamp\www\startup\version1\inc\suggestions.php on line 3

It looks like it is trying to require "suggestions.php", but that is not what I am instructing it to require. Or am I wrong?

2 Answers

I'm not that far into the php track yet but see if this link helps you:
http://stackoverflow.com/questions/14192210/defining-the-document-root-directory-as-the-root-path

Have you defined the ROOT_PATH constant anywhere yet?

Hello,

I'm with Jason on this one. The parsing error is telling you that you haven't defined ROOT_PATH in your file or in any files that you've included. Make sure that you have define('ROOT_PATH', 'value'); where 'value' is the location of the root. This declaration must come before using the constant in your code. Check all files that you've included in your script or the script itself and make sure that declaration has been done. This should get your code to work.

Cheers!