1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help With Parse Error

Discussion in 'PHP & Perl' started by blackhataffiliate, Oct 20, 2009.

  1. blackhataffiliate

    blackhataffiliate Senior Member

    Joined:
    Oct 19, 2008
    Messages:
    847
    Likes Received:
    1,364
    Location:
    USA
    Okay, here is a basic contact form. I keep getting the following parse error. I know it is something simple, but I cant find it. Can some one please help me figure this out, it is driving me crazy.

    Error is Parse error: syntax error, unexpected '@' in............contact/sendmail.php on line 16

    Code:
    <?php
    if(isset($_POST['submit'])) {
    
    $to = "email";
    $subject = "Contact Form Results";
    $name_field = $_POST['sender_name'];
    $email_field = $_POST['sender_email'];
    $message = $_POST['message'];
     
    $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
     
    echo "Data has been submitted to $to!";
    mail($to, $subject, $body);
    
    else {
    
    echo "Thank you for contacting us. Please allow up to 48 business hours for a reply!";
    
    }
    ?>
    
     
  2. showboytridin

    showboytridin Regular Member

    Joined:
    Sep 5, 2009
    Messages:
    348
    Likes Received:
    714
    Location:
    127.0.0.1
    Miss a '}'.

    This should work:
    Code:
    <?php
    if(isset($_POST['submit'])) {
    
    $to = "email";
    $subject = "Contact Form Results";
    $name_field = $_POST['sender_name'];
    $email_field = $_POST['sender_email'];
    $message = $_POST['message'];
     
    $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
     
    echo "Data has been submitted to $to!";
    mail($to, $subject, $body);
    
    }
    
    else {
    
    echo "Thank you for contacting us. Please allow up to 48 business hours for a reply!";
    
    }
    ?>
    
     
    • Thanks Thanks x 1
  3. blackhataffiliate

    blackhataffiliate Senior Member

    Joined:
    Oct 19, 2008
    Messages:
    847
    Likes Received:
    1,364
    Location:
    USA
    Thanks for your help. If you only knew how long I looked for that. I am new to php and the simplest error gets me hung up for ever.
     
  4. showboytridin

    showboytridin Regular Member

    Joined:
    Sep 5, 2009
    Messages:
    348
    Likes Received:
    714
    Location:
    127.0.0.1
    You welcome. You can use a editor that shows that kind of errors. I use the PHP Eclipse editor. It 's a very good help.
     
  5. blackhataffiliate

    blackhataffiliate Senior Member

    Joined:
    Oct 19, 2008
    Messages:
    847
    Likes Received:
    1,364
    Location:
    USA
    Thanks for the info, you have been very helpful.