php - Parse error: syntax error, unexpected T_STRING from W3Schools -


i'm trying create form non-profit. can't seem figure out what's wrong function copied , pasted w3schools.

i've wrapped else in own php tags , still getting error, it's somewhere right here.

function test_input($data) {     $data = trim($data);     $data = stripslashes($data);     $data = htmlspecialchars($data);     return $data; } 

i'm sure question every night but, i've been searching hours , still can't figure out. wish there tool somewhere find messed up.

edit

<?php //define variables , set empty values $nameerr = $teamnameerr = $teamcaptainerr = $addresserr = $phoneerr = ""; $name = $teamname = $teamcaptain = $address = $phone = ""; if ($_server["request_method"] == "post") {     if (empty($_post["name"])) {         $nameerr = "name required"; }         else {          $name = test_input($_post["name"]);         }     if (empty($_post["teamname"])) {         $teamnameerr = "teamname required"; }         else {          $name = test_input($_post["teamname"]);         }     if (empty($_post["teamcaptain"])) {         $teamcaptainerr = "name required"; }         else {          $name = test_input($_post["teamcaptain"]);         }     if (empty($_post["address"])) {         $addresserr = "adress required"; }         else {          $name = test_input($_post["address"]);         }     if (empty($_post["phone"])) {         $phoneerr = "phone number required"; }         else {          $name = test_input($_post["phone"]);         }?><?php function test_input($data) {   $data = trim($data);   $data = stripslashes($data);   $data = htmlspecialchars($data);   return $data; } ?> 

you have missing closing brace } go before first closing ?> tag.

this match closing for:

if ($_server["request_method"] == "post") { 

<?php //define variables , set empty values $nameerr = $teamnameerr = $teamcaptainerr = $addresserr = $phoneerr = ""; $name = $teamname = $teamcaptain = $address = $phone = ""; if ($_server["request_method"] == "post") {     if (empty($_post["name"])) {         $nameerr = "name required"; }         else {          $name = test_input($_post["name"]);         }     if (empty($_post["teamname"])) {         $teamnameerr = "teamname required"; }         else {          $name = test_input($_post["teamname"]);         }     if (empty($_post["teamcaptain"])) {         $teamcaptainerr = "name required"; }         else {          $name = test_input($_post["teamcaptain"]);         }     if (empty($_post["address"])) {         $addresserr = "adress required"; }         else {          $name = test_input($_post["address"]);         }     if (empty($_post["phone"])) {         $phoneerr = "phone number required"; }         else {          $name = test_input($_post["phone"]);         }  } // <- 1 missing  ?>  <?php function test_input($data) {   $data = trim($data);   $data = stripslashes($data);   $data = htmlspecialchars($data);   return $data; } ?> 

footnotes:

you can copy of notepad++ http://notepad-plus-plus.org/ in pair matching.

it's free source code editor , tool use when writing code.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -