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 Logging

Parse error not logged after adding the requested settings to .htaccess

Although I added the last two Settings for .htaccess File (see below) as showed in the video parse errors haven't been logged (Workspace Environment!):

[04-Aug-2020 11:04:10 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/treehouse/workspace/logging.php on line 9
[04-Aug-2020 11:13:24 UTC] PHP Notice:  Undefined variable: errors in /home/treehouse/workspace/logging.php on line 9
[04-Aug-2020 11:13:24 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/treehouse/workspace/logging.php on line 9
[04-Aug-2020 11:16:02 UTC] PHP Notice:  Undefined variable: errors in /home/treehouse/workspace/logging.php on line 9
[04-Aug-2020 11:16:02 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/treehouse/workspace/logging.php on line 9

Console:

treehouse:~/workspace$ php logging.php                                                                                                                                                           
PHP Parse error:  syntax error, unexpected '}', expecting ',' or ';' in /home/treehouse/workspace/logging.php on line 11                                                                         
treehouse:~/workspace$

.htaccess:

# PHP error handling for development servers

# display startup errors
php_flag display_startup_errors On

# display all other errors
php_flag display_errors On

# specify recording of all php errors
php_value error_reporting -1

# html markup of errors, make them easier to read
php_flag html_errors On

# log errors
php_value log_errors 1

# log file for errors
php_value error_log php-error.txt

Is there a problem with the workspace environment or a mistake in my settings? Thank you in advance for any advice.

I'm having the exact same issue. Were you ever able to resolve it?

Also unable to get errors to log to php_error.txt after modifying. I also googled "htaccess php log errors" and tried some other solutions and those didn't work, either.

PS. This has been broken for at least two years per these comments. Does anyone from Treehouse review comments or the smiley face feedback that pops at the end of lessons?

1 Answer

Rachel Johnson
STAFF
Rachel Johnson
Treehouse Teacher

Hey devis , Amelia Groen , and Timothy Andes , thanks for reaching out and posting about this! After a bit of testing we have determined that .htaccess changes can only be done with a Local Dev environment due to the nature of servers. We have added an instruction step to this Course to suggest that students use a Local Dev environment if they'd like to follow along: https://teamtreehouse.com/library/basic-error-handling-in-php/before-you-start

Thanks for bringing this to our attention!