How to echo error from foreach loop?

Cannot figure out this php error?

  • error=Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/a2961838/public_html/index.html on line 102 code=<?php /* File login_reg_form.inc */ include("functions.inc"); ?> <head><title>User Login Page</title> <style type='text/css'> <!-- label { font-weight: bold; float: left; width: 27%; margin-right: .5em; text-align: right; } legend { font-weight: bold; font-size: 1.2em margin-bottom: .5em; } #wrapper { margin: 0; padding: 0; } #login { position: absolute; left: 0; width: 40%; padding: lem 0; } #reg { position:absolute; left: 40%; width: 60%; padding: lem 0; } #field {padding-bottom: .5em;} .errors { font-weight: bold; font-style: italic; font-size: 90%; color: red; margin-top: 0; } --> </style> </head> <body style="margin: 0"> <?php $fields_1 = array("fusername" => "User Name", "fpassword" => "Password" ); $fields_2 = array("user_name" => "User Name", "password" => "Password", "first_name" => "Firstname", "last_name" => "Lastname", ); ?> <div id="wrapper"> <div id="login"> <form action=<?php echo $_SERVER['PHP_SELF']?> method="POST"> <fieldset style='border: 2px solid #000000'> <legend>Login Form</legend> <?php if (isset($message_1)) { echo "<p class='errors'>$message_1</p>\n"; } foreach($fields_1 as $field => $value) { if(preg_match("/pass/i",$field)) $type = "password"; else $type = "text"; echo "<div id='field'> <label for='$field'>$value</label> <input id='$field' name='$field' type='$type' value='".@$$field."' size='20' maxlength='50' /> </div>\n"; } ?> <input type="submit" name="Button" style='margin-left: 45%; margin-bottom: .5em' value="Login" /> </fieldset> </form> <p style='text-align: center; margin: 1em'> If you alredy have an account log in.</p> <p style='text-align: center; margin: 1em'> If you dont have an account register *****.</p> </div> <div id="reg"> <form action=<?php echo $_SERVER['PHP_SELF']?> method="POST"> <fieldset style='border: 2px solid #000000'> <legend>Registration Form</legend> <?php if(isset($message_2)) { echo "<p class='errors'>$message_2</p>\n" } foreach($fields_2 as $field => $value) { if($field == "state") { echo "<div id='field'> <label for='$field'>$value</label> <select name='state' id='state'>"; $stateName=getStateName(); $stateCode=getStateCode(); for ($n=1;$<=50;$n++) { $state=$stateName[$n]; $scode=$stateCode[$n]; echo"<option value='$scode'"; if ($scode== "AL") echo " selected"; echo ">$state</option>\n"; } echo"</select></div>"; } else { if(preg_match("/pass/i",field)) $type = "password"; else $type = "text"; echo "div id='field'> <label for='$field'>$value</label> <input id='$field' name='$field' type='$type' value='".@$$field."' size='40' maxlength='65' /> </div>\n"; } //end else } //end foreach field ?> <input type="submit" name="Button" style='margin left: 45%; margin bottom: .5em' value="Register"> </fieldset> </form> </div> </div> </body></html>

  • Answer:

    Very obvious, you should see this at a glance. There is a missing line terminating ; on one of your echo statements.

Alexande... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.