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 Integrating PHP with Databases Limiting Records in SQL Setting LIMITs

Alex Bauer
Alex Bauer
9,426 Points

What is the parse error in my code?

I've downloaded the zip file in following video after this code was implemented, made sure everything was exactly the same as the my code, I run it through the console and it tells me "PHP Parse error: syntax error, unexpected end of file in /home/treehouse/workspace/catalog.php on line 79.

Every other page and file is correct but it seems that there's something wrong with functions.php or catalog.php and I can't understand what that would be. If anyone could help I'd really appreciate it!

Screenshot to my code: https://w.trhou.se/jfpey7h5rk

1 Answer

Patrick Marshall
Patrick Marshall
13,508 Points

Hi Alex,

Since displaying parsing errors is disabled on Workspaces is disabled I downloaded the project to my computer and put it in PHPStorm, which you can use for free for 30 days from https://www.jetbrains.com/phpstorm/. Possibly the best IDE when developing PHP code. Along with parse errors it also shows other possible errors.

Parsing errors are hard to isolate even when parsing is enabled, so alternatively you would have to go line by line and look at your code to find them.

Other errors such as the ones found in your functions.php file can be displayed with the following code in Workspaces:

error_reporting(E_ALL);
ini_set('display_errors', 1);

That being said, the issues I found were as follows:

You did not close your if structures on lines 39 and 45 of catalog.php.
In functions.php lines 13, 17 and 22 you're using the wrong variable; it should be $results, not $result.

Once I corrected these issues in Workspaces and previewed the site again all was well.

Hope this helps.

Alex Bauer
Alex Bauer
9,426 Points

Thank you so much, you're the best!! I'll definitely check out phpstorm and I'll try the error_reporting method in workspaces so that I can have a better chance of figuring it out on my own in the future!