Im sure its a stupid error..

  • georanson
  • Beginner
  • Beginner
  • User avatar
  • Joined: Aug 10, 2007
  • Posts: 53
  • Loc: florida
  • Status: Offline

Post June 12th, 2011, 8:20 pm

Parse error: syntax error, unexpected T_VARIABLE in D:\Hosting\4952260\html\wp-includes\email.php on line 4

I feel like an idiot for asking but for the life of me I cant figure out what that error is

PHP Code: [ Select ]
 
<?php
if(isset($_POST['email'])) {
     
    $email_to ="georanson@gmail-com";
    $email_subject = "Contact Form";
     
     
    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }
     
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
    }
     
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // required
     
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
     
    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Telephone: ".clean_string($telephone)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";
     
 
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); 
?>
 
<!-- include your own success html here -->
 
Thank you for contacting us. We will be in touch with you very soon.
 
<?php
}
?>
 
  1.  
  2. <?php
  3. if(isset($_POST['email'])) {
  4.      
  5.     $email_to ="georanson@gmail-com";
  6.     $email_subject = "Contact Form";
  7.      
  8.      
  9.     function died($error) {
  10.         // your error code can go here
  11.         echo "We are very sorry, but there were error(s) found with the form you submitted. ";
  12.         echo "These errors appear below.<br /><br />";
  13.         echo $error."<br /><br />";
  14.         echo "Please go back and fix these errors.<br /><br />";
  15.         die();
  16.     }
  17.      
  18.     // validation expected data exists
  19.     if(!isset($_POST['first_name']) ||
  20.         !isset($_POST['last_name']) ||
  21.         !isset($_POST['email']) ||
  22.         !isset($_POST['telephone']) ||
  23.         !isset($_POST['comments'])) {
  24.         died('We are sorry, but there appears to be a problem with the form you submitted.');      
  25.     }
  26.      
  27.     $first_name = $_POST['first_name']; // required
  28.     $last_name = $_POST['last_name']; // required
  29.     $email_from = $_POST['email']; // required
  30.     $telephone = $_POST['telephone']; // not required
  31.     $comments = $_POST['comments']; // required
  32.      
  33.     $error_message = "";
  34.     $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  35.   if(!preg_match($email_exp,$email_from)) {
  36.     $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  37.   }
  38.     $string_exp = "/^[A-Za-z .'-]+$/";
  39.   if(!preg_match($string_exp,$first_name)) {
  40.     $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  41.   }
  42.   if(!preg_match($string_exp,$last_name)) {
  43.     $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  44.   }
  45.   if(strlen($comments) < 2) {
  46.     $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  47.   }
  48.   if(strlen($error_message) > 0) {
  49.     died($error_message);
  50.   }
  51.     $email_message = "Form details below.\n\n";
  52.      
  53.     function clean_string($string) {
  54.       $bad = array("content-type","bcc:","to:","cc:","href");
  55.       return str_replace($bad,"",$string);
  56.     }
  57.      
  58.     $email_message .= "First Name: ".clean_string($first_name)."\n";
  59.     $email_message .= "Last Name: ".clean_string($last_name)."\n";
  60.     $email_message .= "Email: ".clean_string($email_from)."\n";
  61.     $email_message .= "Telephone: ".clean_string($telephone)."\n";
  62.     $email_message .= "Comments: ".clean_string($comments)."\n";
  63.      
  64.  
  65. $headers = 'From: '.$email_from."\r\n".
  66. 'Reply-To: '.$email_from."\r\n" .
  67. 'X-Mailer: PHP/' . phpversion();
  68. @mail($email_to, $email_subject, $email_message, $headers); 
  69. ?>
  70.  
  71. <!-- include your own success html here -->
  72.  
  73. Thank you for contacting us. We will be in touch with you very soon.
  74.  
  75. <?php
  76. }
  77. ?>
  78.  
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 12th, 2011, 8:20 pm

  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Joined: Jun 21, 2006
  • Posts: 485
  • Loc: Conroe, Texas
  • Status: Offline

Post June 12th, 2011, 8:25 pm

Code: [ Select ]
<?php
if(isset($_POST['email'];)) {
  1. <?php
  2. if(isset($_POST['email'];)) {


take out the space and add the ; and that should fix it..
Thanks, Josh --DemonMaestro
www.LilNetwork.com
Fun Website www.ShoutsCloud.com
  • georanson
  • Beginner
  • Beginner
  • User avatar
  • Joined: Aug 10, 2007
  • Posts: 53
  • Loc: florida
  • Status: Offline

Post June 12th, 2011, 8:33 pm

nope that gave me a new error
Parse error: syntax error, unexpected ';', expecting ',' or ')' in D:\Hosting\4952260\html\wp-includes\email.php on line 2
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post June 12th, 2011, 9:04 pm

Problem #1 (Not your problem)
PHP Code: [ Select ]
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
    }
     
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // required
  1.     // validation expected data exists
  2.     if(!isset($_POST['first_name']) ||
  3.         !isset($_POST['last_name']) ||
  4.         !isset($_POST['email']) ||
  5.         !isset($_POST['telephone']) ||
  6.         !isset($_POST['comments'])) {
  7.         died('We are sorry, but there appears to be a problem with the form you submitted.');      
  8.     }
  9.      
  10.     $first_name = $_POST['first_name']; // required
  11.     $last_name = $_POST['last_name']; // required
  12.     $email_from = $_POST['email']; // required
  13.     $telephone = $_POST['telephone']; // not required
  14.     $comments = $_POST['comments']; // required

In the comment for the telephone number, you are saying that it isn't required and yet you make it required by checking if it exists in the if statement right above it.

As to why you are getting that error, that is beyond me... that error is because of a problem with code written before it... if you are just showing a little bit of a file, post some lines before the line with the error... everything looks fine the way it is right now...
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Joined: Jun 21, 2006
  • Posts: 485
  • Loc: Conroe, Texas
  • Status: Offline

Post June 12th, 2011, 9:31 pm

okay may be stupid but just try taking back out the ; and add a space inbetween the = and the " like this.

$email_to = "georanson@gmail-com";

and shouldn't the email be @gmail.com not @gmail-com??? lol
Thanks, Josh --DemonMaestro
www.LilNetwork.com
Fun Website www.ShoutsCloud.com
  • georanson
  • Beginner
  • Beginner
  • User avatar
  • Joined: Aug 10, 2007
  • Posts: 53
  • Loc: florida
  • Status: Offline

Post June 12th, 2011, 9:35 pm

yeah i know the email is .com but the forum told me my email was a link and wouldn't let me post and il try that
  • georanson
  • Beginner
  • Beginner
  • User avatar
  • Joined: Aug 10, 2007
  • Posts: 53
  • Loc: florida
  • Status: Offline

Post June 12th, 2011, 9:37 pm

still the same error. the file is on its own it connects to another html file but thats it
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post June 12th, 2011, 10:09 pm

Line 4 is:
PHP Code: [ Select ]
    $email_to ="georanson@gmail-com";

Correct?
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • georanson
  • Beginner
  • Beginner
  • User avatar
  • Joined: Aug 10, 2007
  • Posts: 53
  • Loc: florida
  • Status: Offline

Post June 13th, 2011, 5:34 am

correct
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8925
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Online

Post June 13th, 2011, 10:41 am

To me it looks like the encoding on your file is messed up which can cause the PHP parser to fail. When I copied and pasted your code directly into nano to do a quick test, I did get the same error as you, but also noticed as I moved my cursor around throughout the file weird characters start showing up which is typical of wrong encodings set on files. What I would recommend to you would be to try and either fix the encoding on the file, or completely start a new file and rewrite everything you see there without copying and pasting so that you do not paste any of the corrupt values over.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post June 14th, 2011, 12:04 pm

Or just use notepad++... it lets you choose your encoding.

PHP Code: [ Select ]
 
<?php
if(isset($_POST['email'])) {
     
    $email_to ="georanson@gmail-com";
    $email_subject = "Contact Form";
     
     
    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }
     
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
    }
     
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // required
     
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
     
    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Telephone: ".clean_string($telephone)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";
     
 
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
 
<!-- include your own success html here -->
 
Thank you for contacting us. We will be in touch with you very soon.
 
<?php
}
?>
 
 
  1.  
  2. <?php
  3. if(isset($_POST['email'])) {
  4.      
  5.     $email_to ="georanson@gmail-com";
  6.     $email_subject = "Contact Form";
  7.      
  8.      
  9.     function died($error) {
  10.         // your error code can go here
  11.         echo "We are very sorry, but there were error(s) found with the form you submitted. ";
  12.         echo "These errors appear below.<br /><br />";
  13.         echo $error."<br /><br />";
  14.         echo "Please go back and fix these errors.<br /><br />";
  15.         die();
  16.     }
  17.      
  18.     // validation expected data exists
  19.     if(!isset($_POST['first_name']) ||
  20.         !isset($_POST['last_name']) ||
  21.         !isset($_POST['email']) ||
  22.         !isset($_POST['telephone']) ||
  23.         !isset($_POST['comments'])) {
  24.         died('We are sorry, but there appears to be a problem with the form you submitted.');      
  25.     }
  26.      
  27.     $first_name = $_POST['first_name']; // required
  28.     $last_name = $_POST['last_name']; // required
  29.     $email_from = $_POST['email']; // required
  30.     $telephone = $_POST['telephone']; // not required
  31.     $comments = $_POST['comments']; // required
  32.      
  33.     $error_message = "";
  34.     $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  35.   if(!preg_match($email_exp,$email_from)) {
  36.     $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  37.   }
  38.     $string_exp = "/^[A-Za-z .'-]+$/";
  39.   if(!preg_match($string_exp,$first_name)) {
  40.     $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  41.   }
  42.   if(!preg_match($string_exp,$last_name)) {
  43.     $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  44.   }
  45.   if(strlen($comments) < 2) {
  46.     $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  47.   }
  48.   if(strlen($error_message) > 0) {
  49.     died($error_message);
  50.   }
  51.     $email_message = "Form details below.\n\n";
  52.      
  53.     function clean_string($string) {
  54.       $bad = array("content-type","bcc:","to:","cc:","href");
  55.       return str_replace($bad,"",$string);
  56.     }
  57.      
  58.     $email_message .= "First Name: ".clean_string($first_name)."\n";
  59.     $email_message .= "Last Name: ".clean_string($last_name)."\n";
  60.     $email_message .= "Email: ".clean_string($email_from)."\n";
  61.     $email_message .= "Telephone: ".clean_string($telephone)."\n";
  62.     $email_message .= "Comments: ".clean_string($comments)."\n";
  63.      
  64.  
  65. $headers = 'From: '.$email_from."\r\n".
  66. 'Reply-To: '.$email_from."\r\n" .
  67. 'X-Mailer: PHP/' . phpversion();
  68. @mail($email_to, $email_subject, $email_message, $headers);
  69. ?>
  70.  
  71. <!-- include your own success html here -->
  72.  
  73. Thank you for contacting us. We will be in touch with you very soon.
  74.  
  75. <?php
  76. }
  77. ?>
  78.  
  79.  
"Bring forth therefore fruits meet for repentance:" Matthew 3:8

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: Bigwebmaster and 152 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.