Monday 15 March 2010

Coding Academy 2015 magazine - PHP Unexpected T_String -


I am currently learning PHP in Coding Academy 2015 magazine. The tutorial was all running well until I came to the following error:

Parse error: Syntax error, unexpected 'check_for_res' in /home/u345668349/public_html/warddesign2/f1calendar.php (T_ITRI)

Array ('Title' => Australia ',' Location '=>' Melbourne ',' Date '=> '13 / 3/2015' ), 'Malaysia' = & gt; array ('title' = & gt; 'Malaysia', 'location' => 'Kuala Lumpur', 'date' => '27 / 3/2015 '),' China ' = & Gt; array ('title' = & gt; 'sugar', 'location' => 'shanghai', 'date' => '10 / 4/2015 '),' Bahrain '=> ; Array ('title' = & gt; Bahrain, 'location' => 'Sakhir', 'Date' => '17 / 4/2015 '),' span '= & gt; array (' title '= & Gt;' Spanish ',' Location '= & gt;' catalunya ',' date '=> '08 / 5/2015');); Function check_for_res ($ location) {global $ race, $ race_data; $ Location = filter_input (INPUT_POST, 'location', FILTER_SANITIZE_STIRNG, '' location '', 'location', 'location' FILTER_FLAG_STRIP_LOW); If (isset ($ race [$ location])) $ race_data = $ race [$ location]; And $ race_data = 'no matching race found'; Return;}? & Gt; & Lt; Html & gt; & Lt; Head & gt; & Lt; Title & gt; Untitled document & lt; / Title & gt; & Lt; Meta http-equiv = "content type" content = "text / html; charset = ISO-885 9-1" & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form method = "post" & gt; Fieldset & gt; & Lt; Label = "location" & gt; Choose a race: & lt; / Labels & gt; Select name = "location" & gt; & Lt ;? Php foreach ($ location = $ race as the race):? & Gt; Option value = "& lt ;? php echo $ location ;? & gt;" & Gt; & Lt ;? Php echo $ location ;? & Gt; & Lt; / Options & gt; & Lt;

This line does not look like 13, it is written below:

  if (isset ($ _ POST ['location']) check_for_race ( $ _ POST ['location']);  

If someone can help with this, then it will be highly appreciated. I have been done many times through book and code, Even its sequence is changing, but nothing seems to be done.

Losing brackets:

  if (isset ($ _ POST ['location']) check_for_race ($ _ POST ['location']);  

Should be:

  if isset ($ _ POST ['location'])) check_for_race ($ _ POST ['location']); // ^ ---- this notice  

your if () can be better to use curly brackets with statements and loops. Easier:

  if (isset ($ _ POST ['location'] )) {Check_for_race ($ _POST ['location']);}  

No comments:

Post a Comment