...

View Full Version : Php error when run script



clubsoton
02-15-2006, 02:56 PM
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:
www.TheDemoSite.co.uk
Should work fine on most Unix/Linux platforms */

// ------- three variables you MUST change below -------------------------------------------------------
$valid_ref1="http://www.club-amigos.co.uk/contact_test.html";// chamge "Your--domain" to your domain
$valid_ref2="http://www.club-amigos.co.uk/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";
<?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:
www.TheDemoSite.co.uk
Should work fine on most Unix/Linux platforms */

// ------- three variables you MUST change below -------------------------------------------------------
$valid_ref1="http://www.club-amigos.co.uk/contact_test.html";// chamge "Your--domain" to your domain
$valid_ref2="http://www.club-amigos.co.uk/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";
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:

www.TheDemoSite.co.uk */
?>

BaDgEr
02-15-2006, 03:00 PM
$success_sent_msg='{

Should that have the ' in it? 'Cos there's two, one on line 38, and one on line 99.

MRMAN
02-15-2006, 03:02 PM
$success_sent_msg='{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
think thats your problem.
$success_sen_msg='{ ...
there is no end ' nor ;

degsy
02-15-2006, 03:03 PM
1) What not look at what line 44 and preceeding lines are
2) Use an editor with syntax highllighting so you can see string errors
3) use the PHP or CODE tags when posting code


What is this?


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


Not sure if you are wanting to print that or assign it to a variable, but you have syntax errors.

clubsoton
02-15-2006, 03:07 PM
I am trying to call up an html file, but don't know the syntax to do this.
That is the cause of the error.

clubsoton
02-16-2006, 08:43 AM
1) What not look at what line 44 and preceeding lines are
2) Use an editor with syntax highllighting so you can see string errors
3) use the PHP or CODE tags when posting code


What is this?


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


Not sure if you are wanting to print that or assign it to a variable, but you have syntax errors.
===========================
Thanks for that, the only minor query l have now is which bit of the code l need to delete so that the sender does not receive a receipt email.
Is this the coding l need to delete?

// 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;
}

clubsoton
02-16-2006, 09:05 AM
Thanks for that, the only minor query l have now is which bit of the code l need to delete so that the sender does not receive a receipt email.
Is this the coding l need to delete?

// 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;
}

degsy
02-16-2006, 02:12 PM
$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;
*/

clubsoton
02-16-2006, 02:35 PM
Thanks for that, thats really helpful.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum