By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,046 Members | 2,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,046 IT Pros & Developers. It's quick & easy.

Parse error: syntax error, unexpected T_VARIABLE

P: 2
I am gettin a error message on this script can someone help me. I am a complete newbie on this stuff. Thanks in advance for any help you can give me.
here is the error.
Parse error: syntax error, unexpected T_VARIABLE in /home/content/m/i/x/mixxsalon/html/FormToEmail.php on line 1

here is the code.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $my_email = "user@example.com";
  4.  
  5. /*
  6.  
  7. Enter the continue link to offer the user after the form is sent.  If you do not change this, your visitor will be given a continue link to your homepage.
  8.  
  9. If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm"
  10.  
  11. */
  12.  
  13. $continue = "/";
  14.  
  15. /*
  16.  
  17. Step 3:
  18.  
  19. Save this file (FormToEmail.php) and upload it together with your webpage containing the form to your webspace.  IMPORTANT - The file name is case sensitive!  You must save it exactly as it is named above!  Do not put this script in your cgi-bin directory (folder) it may not work from there.
  20.  
  21. THAT'S IT, FINISHED!
  22.  
  23. You do not need to make any changes below this line.
  24.  
  25. */
  26.  
  27. $errors = array();
  28.  
  29. // Remove $_COOKIE elements from $_REQUEST.
  30.  
  31. if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
  32.  
  33. // Check all fields for an email header.
  34.  
  35. function recursive_array_check_header($element_value)
  36. {
  37.  
  38. global $set;
  39.  
  40. if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i",$element_value)){$set = 1;}}
  41. else
  42. {
  43.  
  44. foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);}
  45.  
  46. }
  47.  
  48. }
  49.  
  50. recursive_array_check_header($_REQUEST);
  51.  
  52. if($set){$errors[] = "You cannot send an email header";}
  53.  
  54. unset($set);
  55.  
  56. // Validate email field.
  57.  
  58. if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))
  59. {
  60.  
  61. if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or a colon";}
  62.  
  63. $_REQUEST['email'] = trim($_REQUEST['email']);
  64.  
  65. if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}
  66.  
  67. }
  68.  
  69. // Check referrer is from same site.
  70.  
  71. if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
  72.  
  73. // Check for a blank form.
  74.  
  75. function recursive_array_check_blank($element_value)
  76. {
  77.  
  78. global $set;
  79.  
  80. if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
  81. else
  82. {
  83.  
  84. foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
  85.  
  86. }
  87.  
  88. }
  89.  
  90. recursive_array_check_blank($_REQUEST);
  91.  
  92. if(!$set){$errors[] = "You cannot send a blank form";}
  93.  
  94. unset($set);
  95.  
  96. // Display any errors and exit if errors exist.
  97.  
  98. if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;}
  99.  
  100. if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}
  101.  
  102. // Build message.
  103.  
  104. function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}
  105.  
  106. $message = build_message($_REQUEST);
  107.  
  108. $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."";
  109.  
  110. $message = stripslashes($message);
  111.  
  112. $subject = "FormToEmail Comments";
  113.  
  114. $headers = "From: " . $_REQUEST['email'];
  115.  
  116. mail($my_email,$subject,$message,$headers);
  117.  
  118. ?>
  119.  
  120. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  121.  
  122. <html>
  123.  
  124. <head>
  125. <title>Dreamweaver Tutorial - Contact Form</title>
  126. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  127. </head>
  128.  
  129. <body bgcolor="#ffffff" text="#000000">
  130.  
  131. <div>
  132. <center>
  133. <b>Thank you <?php print stripslashes($_REQUEST['name']); ?></b>
  134. <br>Your message has been sent
  135. <p><a href="<?php print $continue; ?>">Click here to continue</a></p>
  136. <p><b>Dreamweaver Spot</b> by <a href="http://dreamweaverspot.com">dreamweaverspot.com</a></p>
  137. </center>
  138. </div>
  139.  
  140. </body>
  141. </html>
Thanks again,
Don
Oct 16 '09 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
the only thing Id suspect would be a Byte Order Mark (some editors place it at the beginning of a file to indicate its UTF encoded)
Oct 16 '09 #2

P: 2
@Dormilich
Where can I find this Byte Order Mark and removed it?
Oct 16 '09 #3

Atli
Expert 5K+
P: 5,058
Hey.

Try using Notepad++.
Open the file in that and from the "Format" menu select: "Convert to UTF8 without BOM".
Oct 16 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.