Jump to content
xisto Community
Sign in to follow this  
adly3000

Php Error When Running Script Php error when running script

Recommended Posts

Hello,

I get the following error:

Parse error: syntax error, unexpected T_STRING in /usr/local/psa/home/vhosts/club-amigos.co.uk/httpdocs/contact.php on line 44

when l run the following script:
Any help would be appreciated.

<?php /* PHP Form Mailer - phpFormMailer v2.1, last updated 30th Nov 2005 - check back often for updates! (easy to use and more secure than many cgi form mailers) FREE from: http://www.thedemosite.co.uk/ Should work fine on most Unix/Linux platforms */ // ------- three variables you MUST change below ------------------------------------------------------- $valid_ref1="http://adly3000.trap17.com/contact_test.html";// chamge "Your--domain" to your domain $valid_ref2="http://adly3000.trap17.com/contact_test.html";// chamge "Your--domain" to your domain $replyemail="EMAIL REMOVED - Send PM to This User Instead";//change to your email address // ------------------------------------------------------------ //clean input in case of header injection attempts! function clean_input_4email($value, $check_all_patterns = true) { $patterns[0] = '/content-type:/'; $patterns[1] = '/to:/'; $patterns[2] = '/cc:/'; $patterns[3] = '/bcc:/'; if ($check_all_patterns) { $patterns[4] = '/\r/'; $patterns[5] = '/\n/'; $patterns[6] = '/%0a/'; $patterns[7] = '/%0d/'; } //NOTE: can use str_ireplace as this is case insensitive but only available on PHP version 5.0. return preg_replace($patterns, "", strtolower($value)); } $name = clean_input_4email($_POST["name"]); $email = clean_input_4email($_POST["email"]); $thesubject = clean_input_4email($_POST["thesubject"]); $themessage = clean_input_4email($_POST["themessage"], false); $error_msg='ERROR - not sent. Try again.'; $success_sent_msg='{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; } // email variable not set - load $valid_ref1 page if (!isset($_POST['email'])) { echo "<script language=\"JavaScript\"><!--\n "; echo "top.location.href = \"$valid_ref1\"; \n// --></script>"; exit; } $ref_page=$_SERVER["HTTP_REFERER"]; $valid_referrer=0; if($ref_page==$valid_ref1) $valid_referrer=1; elseif($ref_page==$valid_ref2) $valid_referrer=1; if(!$valid_referrer) { echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n"; echo "top.location.href = \"$valid_ref1\"; \n// --></script>"; exit; } $themessage = "name: $name \nQuery: $themessage"; [code]<?php /* PHP Form Mailer - phpFormMailer v2.1, last updated 30th Nov 2005 - check back often for updates! (easy to use and more secure than many cgi form mailers) FREE from: http://www.thedemosite.co.uk/ Should work fine on most Unix/Linux platforms */ // ------- three variables you MUST change below ------------------------------------------------------- $valid_ref1="http://forums.xisto.com/no_longer_exists/ chamge "Your--domain" to your domain $valid_ref2="http://forums.xisto.com/no_longer_exists/ chamge "Your--domain" to your domain $replyemail="EMAIL REMOVED - Send PM to This User Instead";//change to your email address // ------------------------------------------------------------ //clean input in case of header injection attempts! function clean_input_4email($value, $check_all_patterns = true) { $patterns[0] = '/content-type:/'; $patterns[1] = '/to:/'; $patterns[2] = '/cc:/'; $patterns[3] = '/bcc:/'; if ($check_all_patterns) { $patterns[4] = '/\r/'; $patterns[5] = '/\n/'; $patterns[6] = '/%0a/'; $patterns[7] = '/%0d/'; } //NOTE: can use str_ireplace as this is case insensitive but only available on PHP version 5.0. return preg_replace($patterns, "", strtolower($value)); } $name = clean_input_4email($_POST["name"]); $email = clean_input_4email($_POST["email"]); $thesubject = clean_input_4email($_POST["thesubject"]); $themessage = clean_input_4email($_POST["themessage"], false); $error_msg='ERROR - not sent. Try again.'; $success_sent_msg='{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; } // email variable not set - load $valid_ref1 page if (!isset($_POST['email'])) { echo "<script language=\"JavaScript\"><!--\n "; echo "top.location.href = \"$valid_ref1\"; \n// --></script>"; exit; } $ref_page=$_SERVER["HTTP_REFERER"]; $valid_referrer=0; if($ref_page==$valid_ref1) $valid_referrer=1; elseif($ref_page==$valid_ref2) $valid_referrer=1; if(!$valid_referrer) { echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n"; echo "top.location.href = \"$valid_ref1\"; \n// --></script>"; exit; } $themessage = "name: $name \nQuery: $themessage"; mail("$replyemail", "$thesubject", "$themessage", "From: $email\nReply-To: $email"); mail("$email", "Receipt: $thesubject", "$replymessage", "From: $replyemail\nReply-To: $replyemail"); echo $success_sent_msg; /* PHP Form Mailer - phpFormMailer (easy to use and more secure than many cgi form mailers) FREE from: http://www.thedemosite.co.uk/ */ ?>

Share this post


Link to post
Share on other sites

This might not be the solution, but I noticed that the following post array element uses only single quotes while the ones above this line (which didn't error) use double quotes to contain the array element name. And the ones below it also use double quotes, too, so maybe I'm on to something here.

Try changing this code to double quotes.

if (!isset($_POST['email']))
I am just learning php, so I might be wrong on this. Post back if this doesn't work and you still need a hand.

Share this post


Link to post
Share on other sites

It makes no difference whether you use double or single quotes when referencing indexes in an array. In fact, unless you absolutely have to, I would recommend using single quotes wherever possible (and not just when working with arrays, but in all aspects of PHP), as it's processed faster.

Anyway, as with most errors in PHP, the actual problem is not on the mentioned line, but prior to that. Take a look at lines 38 to 40:

$success_sent_msg='{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; }

I think you'll find therein lies your error (note the opening quote, but lack of a closing one - I'm also not sure why the squigly braces have been added). I took a quick look at the original script, and the equivalent code was:

$success_sent_msg='<p align="center"><strong> </strong></p>   <p align="center"><strong>Your message has been successfully sent to us<br>   </strong> and we will reply as soon as possible.</p>   <p align="center">A copy of your query has been sent to you.</p>   <p align="center">Thank you for contacting us.</p>';

Hope that helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.