Parse Error

Discussion in 'HTML & Website Design' started by suze, Feb 29, 2008.

  1. #1
    I keep getting a parse error: syntax error, unexpected $end in the code on line 140. Line 140 is the first line after the document is finished. I've been through this 6 times trying to find my error, but I have no idea where to look for it. I have found and fixed several things but none of them have improved the result.

    Can anyone see what I am missing.

    <?php
    if (array_key_exists('ewComments', $_POST)) {
    // mail processing script

    // remove escape characters from POST array
    if (get_magic_quotes_gpc()) {
    function stripslashes_deep($value) {
    $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
    return $value;
    }
    $_POST = array_map('stripslashes_deep', $_POST);
    }
    //validate the input, beginning with name
    $name = trim($_POST['name']);
    if (empty($name)) {
    $error['name'] = 'Please Enter Your Name';
    }

    $email = $_POST['email'];
    // check for valid email address
    $pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
    if (!preg_match($pattern, trim($email))) {
    $error['email'] = 'Please enter a valid email address';
    }

    // check the content of the text area
    $messageBody = trim($_POST['message']);
    if (empty($messageBody)) {
    $error['message'] = 'Please enter your message';
    }

    // initialize variables
    $to = 'ddsuze@shaw.ca'; //use your own email address
    $subject = 'Feedback form East - West Seasons';



    //build the message
    $message = "From: $name\n\n";
    $message .= "Email: $email\n\n";
    $message .= "Comments: $messageBody";

    //build the additional headers
    $additionalHeaders = "From: E-W Seasons<thuseenterprises@gmail.com>\r\n";
    $additionalHeaders .= "Reply-To: $email";

    //send the email if there are no errors
    if (!isset($error)) {
    mail($to, $subject, $message, $additionalHeaders);
    }
    ?>



    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>East-West Seasons</title>
    <?php include('style_rules.php'); ?>
    <script type="text/JavaScript">
    <!--
    function MM_findObj(n, d) { //v4.01
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_validateForm() { //v4.0
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args);
    if (val) { nm=val.name; if ((val=val.value)!="") {
    if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
    if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
    } else if (test!='R') { num = parseFloat(val);
    if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
    if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
    min=test.substring(8,p); max=test.substring(p+1);
    if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
    }
    //-->
    </script>
    </head>

    <body>
    <div id="wrapper">
    <div id="titlebar"><img src="images_common/bluebells_top.jpg" alt="East-West Seasons" /></div>
    <div id="maincontent">
    <div id="nav">
    <ul>
    <li><a href="index.php">Home</a></li>
    <li><a href="news.php">News</a></li>
    <li><a href="blog.php">Blog</a></li>
    <li><a href="gallery.php">Gallery</a></li>
    <li><a href="contact.php">Contact</a></li>
    </ul>
    </div>
    <h1>Send Us Your Comments</h1>

    <p>Ut enim ad minim veniam, sed do eiusmod tempor incididunt ut aliquip ex ea commodo consequat. Ullamco laboris nisi excepteur sint occaecat quis nostrud exercitation. Eu fugiat nulla pariatur. In reprehenderit in voluptate duis aute irure dolor velit esse cillum dolore. Ut enim ad minim veniam, lorem ipsum dolor sit amet, quis nostrud exercitation.</p>



    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name= "contactForm" id="contactForm" onsubmit="MM_validateForm('name','','R','email','','RisEmail','message','','R');return document.MM_returnValue">
    <p>
    <label for="name">Name:</label> <?php if (isset($error['name'])) { ?>
    <span class="warning"><?php echo $error['name']; ?></span>
    <?php } ?>
    <br />
    <input type="text" name="name" id="name" />
    <br />
    </p>
    <p>
    <label for="email">Email:</label>
    <br />
    <input type="text" name="email" id="email" />
    <br />
    </p>
    <p>
    <label for="textfield">Message:</label>
    <br />
    <textarea name="message" cols="60" rows="6" id="message"></textarea>
    </p>
    <p>
    <input name="ewComments" type="submit" id="ewComments" value="Send Comments" />
    </p>

    </form>
    </div>
    <div id="footer">
    <div id="footer"><?php include('copyright.php'); ?>
    </div>
    </div>
    </body>
    </html>
     
    suze, Feb 29, 2008 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    You missed your closing brace.

     
    Colbyt, Mar 1, 2008 IP
  3. suze

    suze Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Your comment about missing the closing brace helped. I went through the php section and found where I had missed one. One } and I had it working.

    Thanks again!
     
    suze, Mar 1, 2008 IP