senca99 Posted October 24, 2010 Share Posted October 24, 2010 hey, I get this error on line 69 which is the end of my code, but I just can't find the missing or wrong curly bracket :s <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <p> <?php if(isset($_POST['_submit_check'])){ if($form_errors = validate_form()){ show_form($form_errors);} else{ process_form();}} else{ show_form();} function process_form(){ print "Hello, ".$_POST['user'];} if(array_key_exists('user', $_POST)){ process_form();} else{ show_form(); } function validate_form(){ $errors = array(); if(strlen($_POST['user']) < 1){ $errors[] = 'Your name must be at least 1 letter long.'; } return $errors;} if(array_key_exists('_submit_check', $_POST)){ if(validate_form()){ proces_form(); } else{ show_form();} } else{ show_form(); } function show_form($errors = ''){ if($errors){ print 'please correct these errors: <ul><li>'; print implode('</li><li>', $errors); print '</li></ul>'; } print<<<_HTML_ <form method = "POST" action="$_SERVER[php_SELF]"> Your name: <input type="text" name="user"> </br> <input type="submit" value="Verzenden"/> </br> <input type="hidden" name="_submit_check_" value="1"> </form> _HTML_; } ?> </p> </body> </html> Link to comment https://forums.phpfreaks.com/topic/216701-parse-error-syntax-error-unexpected-end-in-cant-find-it/ Share on other sites More sharing options...
Yucky Posted October 24, 2010 Share Posted October 24, 2010 if($form_errors = validate_form()) You're using the assignment operator instead of the equality operator. Link to comment https://forums.phpfreaks.com/topic/216701-parse-error-syntax-error-unexpected-end-in-cant-find-it/#findComment-1125846 Share on other sites More sharing options...
senca99 Posted October 24, 2010 Author Share Posted October 24, 2010 that doesn't change a thing. I also noticed in NP++ that the function show_form has no matching "}" after the htmlform part. It only matches if I put it after the first if-statement. But still my "?>" stays gray so there's still something wrong Link to comment https://forums.phpfreaks.com/topic/216701-parse-error-syntax-error-unexpected-end-in-cant-find-it/#findComment-1125848 Share on other sites More sharing options...
senca99 Posted October 24, 2010 Author Share Posted October 24, 2010 after testing every function by marking it as comment I noticed they don't have a negativ effect. The error occurs when "print<<< _HTML_" starts Link to comment https://forums.phpfreaks.com/topic/216701-parse-error-syntax-error-unexpected-end-in-cant-find-it/#findComment-1125852 Share on other sites More sharing options...
Yucky Posted October 24, 2010 Share Posted October 24, 2010 Seemingly you're not allowed to indent the heredoc's closing tag. I suppose you learn something new each day. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <p> <?php if(isset($_POST['_submit_check'])) { if($form_errors == validate_form()) { show_form($form_errors); } else { process_form(); } } else { show_form(); } function process_form() { print "Hello, ".$_POST['user']; } if(array_key_exists('user', $_POST)) { process_form(); } else { show_form(); } function validate_form() { $errors = array(); if(strlen($_POST['user']) < 1) { $errors[] = 'Your name must be at least 1 letter long.'; } return $errors; } if(array_key_exists('_submit_check', $_POST)) { if(validate_form()) { proces_form(); } else { show_form(); } } else { show_form(); } function show_form($errors = '') { if($errors) { print 'please correct these errors: <ul><li>'; print implode('</li><li>', $errors); print '</li></ul>'; } print<<<_HTML_ <form method = "POST" action="$_SERVER[php_SELF]"> Your name: <input type="text" name="user"> </br> <input type="submit" value="Verzenden"/> </br> <input type="hidden" name="_submit_check_" value="1"> </form> _HTML_; } ?> </p> </body> </html> There we go. Link to comment https://forums.phpfreaks.com/topic/216701-parse-error-syntax-error-unexpected-end-in-cant-find-it/#findComment-1125854 Share on other sites More sharing options...
senca99 Posted October 24, 2010 Author Share Posted October 24, 2010 thanks a lot! I would've never found that one :s Solved! Link to comment https://forums.phpfreaks.com/topic/216701-parse-error-syntax-error-unexpected-end-in-cant-find-it/#findComment-1125857 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.