Jump to content

Parse error: syntax error, unexpected $end in => can't find it


senca99

Recommended Posts

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>

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.