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 trialShen JIE LIN
10,612 PointsError when project is run with Sublime 2
I downloaded the project files and tried to run it and this is the error message I got when I ran it in Chrome
"Fatal error: Call to undefined function get_products_recent() in C:\xampp\htdocs\TreeHousePHPTrack\index.php on line 5"
I have not changed anything to the downloaded file and the code "include(ROOT_PATH . "inc/products.php");"
is written before the
"$recent = get_products_recent();"
I checked inside the "products.php" file, and the function is defined, I have even copy-pasted the function name out to replace it again. But... It does not work. I am so confused.
someone please help me
Thanks
3 Answers
Don Shipley
19,488 PointsThe other thing I had to do was to go into inc/config.php and place in the difine properties define("BASE_URL","/treehouse/PHP/project02-stage06-shirts4mike/"); define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/treehouse/PHP/project02-stage06-shirts4mike/"); depending on where your files are located.
Don Shipley
19,488 PointsI had to go into .htaccess RewriteRule ^shirts/$ /shirts/shirts.php and removed all the / like, RewriteRule ^shirts/$ shirts/shirts.php
Shen JIE LIN
10,612 PointsThanks for your reply.
I just tried your method. However, it doesn't work still.
on the other hand, I tried change " include(ROOT_PATH . "inc/products.php"); " to " include ("inc/products.php"); "
and it worked...
therefore, I am thinking it is something wrong with the way the ROOT_PATH definition inside config.php...
BUT....
when I use var_dump() to check the ROOT_PATH . "inc/products.php" value. I get a properly returned address to the file.
I checked the syntax as well.
so I don't know what is going on anymore...
Don Shipley
19,488 PointsI have to change my BASE_URL and ROOT_PATH every time I save a new project file. Also in the index.php also have to chane the link on the button from shirts.php to shirts/ Your BASE_URL and ROOT_SERVER need to see your folder in you localhost dir.
Shen JIE LIN
10,612 PointsShen JIE LIN
10,612 PointsWOOT!
yay, there is the problem.
hehe, I feel pretty stupid right now.
Thanks!!