Parse error: parse error in C:\\wamp\\www\\senderomusical\\danielon.php on line 37
<?php
echo '<div id="tresu">
<p><b>La operacion no pudo ser hecha por favor trate de nuevo</b><br/><br/><br/>
Please resubmit the form after making
the following changes:
<div id="tres">';
echo "<ul>";
foreach (
{ // line 37
echo "<li>" . $e['msg'];
}
echo "</ul>";
echo'</div>
</div>';
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<?php
include("validationclass.php");
$name = $_POST['nombre'];
$apellido = $_POST['apellido'];
$email= $_POST['email'];
$pais = $_POST['pais'];
$ciudad = $_POST['ciudad'];
$message = $_POST['mensaje'];
$fv = new FormValidator();
$fv->isEmpty("name", "Por favor entre su nombre");
$fv->isEmpty("apellido", "Por favor entre suapellido");
$fv->isEmpty("email", "Por favor entre su email");
$fv->isEmpty("pais", "Por favor entre su pais");
$fv->isEmpty("ciudad", "Por favor entre su ciudad");
$fv->isEmpty("mensaje", "Por favor entre su mensaje");
if ($fv->isError())
{
$errors = $fv->getErrorList();
echo '<div id="tresu">
<p><b>La operacion no pudo ser hecha por favor trate de nuevo</b><br/><br/><br/>
Please resubmit the form after making
the following changes:
<div id="tres">';
echo "<ul>";
foreach (
{ //line 37
echo "<li>" . $e['msg'];
}
echo "</ul>";
echo'</div>
</div>';
}
else
{
// do something useful with the data
//TO, Subject, Message, Header
mail('<example@gmail.com>','Contact us Message',$message,$appellido,$pais,$ciudad,$mensaje,'From:'.$name.'<'. $email.'>');
header('Location:mensajedegracias.php');
}
?>
</body>
</html>
the whole code is as above.
That’s a form to be validated and if all the fields are not empty then send the message but the foreach is throwing a parse error.
Rubble
February 7, 2010, 9:57pm
3
foreach ( What? There should be more here
Replace…
foreach (
{ //line 37
echo "<li>" . $e['msg'];
}
…with…
foreach($errors as $e){
echo '<li>', $e['msg'], '</li>';
}
co_ador
February 7, 2010, 10:05pm
5
Yea I had in the other sample page, I was doing the above for a friend of mine and yes I miss the ($errors as $e) thank you very much…