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 trialTakudzwa Karisambudzi
7,157 PointsI 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
14,268 PointsYou 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.
<?php
$error_message = "";
if (!isset($email)) {
$error_message = "Your email address is required.";
}
?>
Takudzwa Karisambudzi
7,157 PointsTakudzwa Karisambudzi
7,157 PointsThanx 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