methuselah
methuselah

Reputation: 13216

unexpected T_VARIABLE error whilst setting up form validation

i am trying to set up form validation but keep receiving Parse error: syntax error, unexpected T_VARIABLE on line 146 whenever i try to load the page.

lines 133-153 of my code are

<?php
    if (array_key_exists('submit',$_POST)){
    //set up layout
    echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" style="height: 140px;">
          <tr>
            <td width="60%" valign="middle"><a href="index.php"><img src="resources/img/kite.png" alt="" width="250" height="101" border="0"/></a></td>
            <td width="40%" align="left" valign="middle"></td>
                  </tr>
                </table>
              </form></td>
          </tr>
        </table>';
         // Fields that are on form
        $expected = array('name', 'email', 'comments');
        // Set required fields
        $required = array('name', 'comments');
        // Initialize array for errors
        $errors = array();
    exit;
    }
    ?>

many thanks in advance!

Upvotes: 0

Views: 490

Answers (1)

Ibu
Ibu

Reputation: 43840

I get this kind of error sometimes when i copy and paste code from an outside source (websource , or microsoft word). Depending on the editor you use, try to see if you have any option to display invisible characters, such as spaces, tabs, and new lines.

You probably have a foreign character that is not visible.

If you don't have such an editor, simply erase the white space in the line causing the problem and add your own white space using a the space bar or tab.

try that and let us know.

Upvotes: 1

Related Questions