co.ador Posted February 7, 2010 Share Posted February 7, 2010 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>'; } ?> Link to comment https://forums.phpfreaks.com/topic/191285-parse-error-on-line-37-help/ Share on other sites More sharing options...
jl5501 Posted February 7, 2010 Share Posted February 7, 2010 foreach what? Link to comment https://forums.phpfreaks.com/topic/191285-parse-error-on-line-37-help/#findComment-1008543 Share on other sites More sharing options...
co.ador Posted February 7, 2010 Author Share Posted February 7, 2010 <!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 ( { echo "<li>" . $e['msg']; } echo "</ul>"; echo'</div> </div>'; } else { // do something useful with the data //TO, Subject, Message, Header mail('<[email protected]>','Contact us Message',$message,$appellido,$pais,$ciudad,$mensaje,'From:'.$name.'<'. $email.'>'); header('Location:mensajedegracias.php'); } ?> </body> </html> 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. Link to comment https://forums.phpfreaks.com/topic/191285-parse-error-on-line-37-help/#findComment-1008547 Share on other sites More sharing options...
jl5501 Posted February 7, 2010 Share Posted February 7, 2010 yes you cannot have foreach by itself you need to give it the array to use like foreach($array as $instance) Link to comment https://forums.phpfreaks.com/topic/191285-parse-error-on-line-37-help/#findComment-1008548 Share on other sites More sharing options...
jl5501 Posted February 7, 2010 Share Posted February 7, 2010 in your case it looks like foreach($errors as $e) { } might work Link to comment https://forums.phpfreaks.com/topic/191285-parse-error-on-line-37-help/#findComment-1008550 Share on other sites More sharing options...
co.ador Posted February 7, 2010 Author Share Posted February 7, 2010 thank you very much for: ($errors as $e) Link to comment https://forums.phpfreaks.com/topic/191285-parse-error-on-line-37-help/#findComment-1008555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.