How to fix Parse error: syntax error, unexpected T_VARIABLE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brkseven
    New Member
    • May 2010
    • 2

    #1

    How to fix Parse error: syntax error, unexpected T_VARIABLE

    Looking for help with this Contact Form.

    The error is on line 1, but that' doesn't mean a lot, I think. In fact, a php syntax check passed it, but I was hoping for an easy syntax error, it looks more complicated now.

    Anyway, here's the error:
    "Parse error: syntax error, unexpected T_VARIABLE in /home/xxx/public_html/yyy/zzz/contactengine.p hp on line 1"

    It's a contact form from css-tricks, when I submit that's what I get.

    Code:
    <?php
    
    $EmailFrom = "xxxxxxxxx@gmail.zzz";
    $EmailTo = "yyyyyyyyy@gmail.zzz";
    $Subject = "Messaggio";
    $Name = Trim(stripslashes($_POST['Name'])); 
    $Tel = Trim(stripslashes($_POST['Tel'])); 
    $Email = Trim(stripslashes($_POST['Email'])); 
    $Message = Trim(stripslashes($_POST['Message'])); 
    
    // validation
    $validationOK=true;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }
    
    // prepare email body text
    $Body = "";
    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";
    $Body .= "Tel: ";
    $Body .= $Tel;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $Email;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $Message;
    $Body .= "\n";
    
    // send email 
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    // redirect to success page 
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    There's no error there. Unless, of course, there is no POST array defined (and you'll get undefined index notices). What exactly is the error?

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Is the code you posted in the file contactengine.p hp? Is this file include()'d by another file?

      Comment

      • brkseven
        New Member
        • May 2010
        • 2

        #4
        First question, answer yes, second answer no...

        <form method="post" action="contact engine.php">

        It's a contact form that I found at css-tricks

        Comment

        Working...