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 Build a Basic PHP Website (2018) Listing and Sorting Inventory Items Sorting Array Items

My code is broken somewhere and I can't find the error.


I have run through the video multiple times checking for syntax and also downloaded the project files, which didn't help, however, my code is still not working and I can't seem to figure out why not.

Here is a snapshot https://w.trhou.se/mbcnhgkcnj

The php environment within workspaces currently has display_errors turned off. This makes it hard to find these kinds of syntax errors.

The staff is currently looking into this and will hopefully get it turned back on.

In the meantime, you can create a .htaccess file in workspaces to turn the errors back on.

Warning! You should only do this for development and not on a live production site.

Create a new file named "htaccess.txt" This is only so you can edit and preview the file. It's not the correct file name.

Add the following:

php_flag display_errors 1

After saving the file, rename it to ".htaccess" That's a dot and then htaccess

Now, instead of getting a blank white page on syntax errors you'll be told the file and line number where the parse error occurs. This should make it easier to fix.

5 Answers

changed from comment to answer

Also, you were missing a right parenthesis on line 12 of functions.php

It should be

if ($category == null) {

Thank you, Juliette, completely missed that. I fixed the error and the one Jason mentioned but still no luck, yet.

I had forked your workspace and fixed those 2 errors and everything seemed to be working correctly for me.

Are you seeing a blank white page or something else?

You can post a new snapshot if you need to.

Thank you both! I appreciate your help! I finally found it! Jason, it was the missing parenthesis on line 12 in functions.php.

You two rock! Thank you again.

Juliette Tworsey
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points


BTW, I just remembered that I came across this cool PHP code checker yesterday. Maybe it can help us all in the future. I know that sometimes looking for an error or syntax typo can sometimes be like looking for a needle in a haystack:-)


Glad you got it working.

It might be good experience for you to try the htaccess file and take the parenthesis back out so you can see what the message looks like and see if it makes sense.

Juliette Tworsey
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

The other thing that I noticed (and I forget why this is necessary & to be honest, I'm going to have to watch the video again myself) is that you do not have a space in between " and "on" on lines 14, 15, 16, & 17:

{ echo "on";}

It should be:

{ echo " on"; }

I hope that this helps:-)

Thanks again Juliette! I'll try those changes.

That part is ok because there's a space before the opening php tags.

<li class="books <?php if ($section == "books"){ echo "on";} ?>">

As long as you put the space after books or before on it will work the same way.

It's preferable to do it the way you have shown so that you don't have a trailing space in the class name if the on class isn't echoed. This doesn't cause any problems though.

The reason for the space is so that the result will be "books on" instead of "bookson" which would cause the css not to work correctly.