473,511 Members | 15,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parse error: syntax error, unexpected T_VARIABLE

2 New Member
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
3 5042
Dormilich
8,658 Recognized Expert Moderator Expert
the only thing I’d suspect would be a Byte Order Mark (some editors place it at the beginning of a file to indicate it’s UTF encoded)
Oct 16 '09 #2
broll911
2 New Member
@Dormilich
Where can I find this Byte Order Mark and removed it?
Oct 16 '09 #3
Atli
5,058 Recognized Expert Expert
Hey.

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

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

Similar topics

6
19010
by: Ehartwig | last post by:
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After...
2
1927
by: aamer | last post by:
can anyone please help me, im getting a dumb: Parse error: syntax error, unexpected T_VARIABLE in /home/jeddah/public_html/lomar/cart/remove.php on line 5 in the following file, <?php...
4
11617
by: bovanshi | last post by:
got this annoying error I'm completly new to php... and i have no clue what is wrong here, from what i can tell there is nothing rong with this code... but that isn't what the borwser say :P ...
5
13134
by: Anna MZ | last post by:
I am new to php and have written the following mysql code to enter the details of a new user in the admin subdomain of my website: $sql = "INSERT INTO 'users' ('userid', 'username', 'upassword')...
1
2296
epots9
by: epots9 | last post by:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/xxx.php on line xxx I get that message when i try to run my...
1
1392
by: mdouble | last post by:
I'm a complete novice with HTML and PHP. Recently I purchased an auto responder that requires me to edit a PHP file during the installation process as per directions provided in a read me file. ...
3
6934
by: SilvaZodiac | last post by:
Hi everyone, I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the...
4
4394
by: needhelp08 | last post by:
I am getting the error Parse error: syntax error, unexpected T_VARIABLE on line 4 but I can't seem to find what is wrong. Could someone please help. <?php $conn = @mysql_connect("localhost",...
5
10011
praclarush
by: praclarush | last post by:
I've just started php, and this is a class assignment, but my question is I’m getting this error PHP Parse error: syntax error, unexpected T_IF, expecting T_VARIABLE or '$' in...
2
3225
by: fburn | last post by:
I need some help with an error I'm getting using php 5.2.5 running on linux. I receive an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or...
0
7251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7148
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
451
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.