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 trialAlex Bauer
9,426 PointsI can't seem to practice my PHP code in the workspace in Treehouse, what am I doing wrong?
I have a list.php file that I downloaded and from Treehouse and pasted the code as a new file into the workspace. Then, I copied the code in the lecture while using the list.php file from the same folder by calling it in the new file using the "include" function as shown by the video. When I run the program I get a blank white page. I've even tried using my own local web server, and I looked over the code for errors a tremendous amount of times. I need to fix this if I want to practice, please help.
Alex Bauer
9,426 Pointsthe switch and conditional files are irrelevant since the todo.php file doesn't call them.
1 Answer
Steven Parker
231,261 PointsDid you try running it from the command line? "php todo.php
"? That's what I did and the error message pointed directly to the syntax error on line 5:
foreach($list as key => $item) {
The identifier "key" should be "$key" (with a dollar sign).
Alex Bauer
9,426 PointsYAY!! Thank you so much! I can't believe I missed that, now it's working perfectly. I didn't run it from the command line, next time I will. I appreciate your help very much, thank you,
Steven Parker
231,261 PointsSteven Parker
231,261 PointsTo facilitate analysis, make a snapshot of your workspace and post the link to it here.