Parse error: syntax error, unexpected T_STRING

Discussion in 'PHP' started by Cyberpaul, Jan 27, 2008.

  1. #1
    Hi guys. Can someone help Me? When im submitting a form, Im getting a "Parse error: syntax error, unexpected T_STRING on line 27" error

    Here's the code... the red part is line 27 on where im getting the error

    
    <?php
    $to = $_REQUEST['sendto'] ;
    $from = $_REQUEST['Email'] ;
    $name = $_REQUEST['Name'] ;
    $headers = "From: $from";
    $subject = "Web Contact Data";
    
    $fields = array();
    $fields{"Name"} = "Name";
    $fields{"Company"} = "Company";
    $fields{"Email"} = "Email";
    $fields{"Phone"} = "Phone";
    $fields{"list"} = "Mailing List";
    $fields{"Message"} = "Message";
    
    $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
    
    $headers2 = "From: paul_agabin@yahoo.com";
    $subject2 = "Thank you for contacting us";
    $autoreply = "Thank you for contacting us.
    
    
    
    
    
    
    [COLOR="Red"]if($from == '') {print "You have not entered an email, please go back and try again"; }[/COLOR]
    else {
    if($name == '') {print "You have not entered a name, please go back and try again"; }
    else {
    
    
    $send = mail($to, $subject, $body, $headers);
    $send2 = mail($from, $subject2, $autoreply, $headers2);
    
    
    
    if($send)
    {header( "Location: http://www.YourDomain.com/thankyou.html" );}
    else
    {print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; }
    }
    }
    
    ?>
    
    Code (markup):
     
    Cyberpaul, Jan 27, 2008 IP
  2. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #2
    $headers2 = "From: paul_agabin@yahoo.com";
    $subject2 = "Thank you for contacting us";
    $autoreply = "Thank you for contacting us.
    Code (markup):
    should be:
    $headers2 = "From: paul_agabin@yahoo.com";
    $subject2 = "Thank you for contacting us";
    $autoreply = "Thank you for contacting us.";
    Code (markup):
     
    papa_face, Jan 27, 2008 IP
  3. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Spot on. Remember, when you get given a line number, it tells you it wasn't expecting what's there. You should check the lines before this to see why. The most common error like this, is because the line preciding it doesn't end in a semi-colon.
     
    jayshah, Jan 27, 2008 IP