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 Enhancing a Simple PHP Application Integrating Validation Errors Setting an Error Message Variable

I am having problems with the $error_message variable. Is it an in-build php variable or not? I cant figure that out

Anyone help... i want to understand the $error_message variable

1 Answer

Jeff Lemay
Jeff Lemay
14,268 Points

You set the variable yourself, it is not pre-built into php. You might set it to equal nothing at first and then, as you run through your validation, append text to it depending on what failed.

$error_message = "";
if (!isset($email)) {
   $error_message = "Your email address is required.";

Thanx for the prompt response that worked after i assigned an empty value.. Referencing tothe task "setting up an error message variable". I tried putting the code below after the if($_SERVER(REQUEST_METHOD) statement:

if(isset($error_message)){ echo $error_message; }

On my preview the results still didnt show as randy's. I was forwarded to the white page with the error message inside the $error_message variable. is there some css styling i missed or somewhere i went wrong