Php error when run script

This is a discussion on "Php error when run script" within the PHP Forum section. This forum, and the thread "Php error when run script are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 15th, 2006, 13:52
Junior Member
Join Date: Jan 2006
Age: 42
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Php error when run script

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: Select all

<?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:
                  [url]www.TheDemoSite.co.uk[/url]
      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="jjr@club-amigos.co.uk";//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:
                  [url]www.TheDemoSite.co.uk[/url]
      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="justin.renn@smiths-aerospace.com";//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:

    [url]www.TheDemoSite.co.uk[/url]       */
?>

Last edited by benbacardi; Feb 15th, 2006 at 20:25.
Reply With Quote

  #2 (permalink)  
Old Feb 15th, 2006, 20:29
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
Re: Php error when run script

your error is around this bit:
PHP: Select all

$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])) 
you havent closed your $success_sent_msg variable, and you are trying to run php code following it as if it were part of the variable...
Reply With Quote
  #3 (permalink)  
Old Feb 16th, 2006, 07:41
Junior Member
Join Date: Jan 2006
Age: 42
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Php error when run script

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





Last edited by jj1234; Feb 16th, 2006 at 08:03.
Reply With Quote
  #4 (permalink)  
Old Feb 17th, 2006, 13:27
Junior Member
Join Date: Jan 2006
Age: 42
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Php error when run script

I have resolved this issue. The thread can now be closed.
Reply With Quote
Reply

Tags
php, error, run, script

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
error in unsubscribe.php script csun PHP Forum 7 Jul 23rd, 2007 17:56
members php script error csun PHP Forum 2 Jul 4th, 2007 06:46
Ie Script error acrikey Starting Out 2 Mar 26th, 2007 14:22
PHP Forgot password script error eddie PHP Forum 4 Mar 4th, 2007 15:43
Another ASP script error message a.jenery Classic ASP 13 Apr 21st, 2006 01:10


All times are GMT. The time now is 20:57.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43