Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Php Error When Running Script, Php error when running script
adly3000
post Feb 17 2006, 06:04 PM
Post #1


Member [Level 1]
****

Group: Members
Posts: 58
Joined: 31-January 06
Member No.: 17,937



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.

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:
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:
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 */
?>
Go to the top of the page
 
+Quote Post
jlhaslip
post Feb 17 2006, 06:39 PM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



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.
CODE
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.
Go to the top of the page
 
+Quote Post
Spectre
post Feb 18 2006, 04:56 AM
Post #3


Privileged Member
*********

Group: Members
Posts: 874
Joined: 30-July 04
Member No.: 246



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:
CODE
$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:

CODE
$success_sent_msg='<p align="center"><strong>&nbsp;</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.
Go to the top of the page
 
+Quote Post
adly3000
post Feb 19 2006, 10:46 PM
Post #4


Member [Level 1]
****

Group: Members
Posts: 58
Joined: 31-January 06
Member No.: 17,937



thanks all.that is helping me to the right way thanks.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Could Someone Make A Php Script For Me?(3)
  2. Php Quiz Script(20)
  3. Error Not A Valid Win32 Application(10)
  4. Free Weather Feed Script(1)
  5. Running Midp Applications(3)
  6. Error Installing Windows Xp -error 7 Ntkrnlmp.exe(10)
  7. Operating System Not Found(13)
  8. New System Shuts Down After Running About 1 Minute(13)
  9. Gmail: 502 Server Error(20)
  10. Watermark Your Image With Simple Php Script(34)
  11. Running Bios Setup On A Dell Inspiron 8000 Laptop(8)
  12. Psp Error- Tut On How To Fix(28)
  13. Html Code Tester. Online Script(15)
  14. Background Image Swap Script(15)
  15. Invite Script..(2)
  1. Error E74? (xbox 360)(7)
  2. Loaing Script(3)
  3. Running, Jogging, Training(38)
  4. Cannot Open Display - Error(2)
  5. Coppermine Gallery Error(2)
  6. Page Load Error When Accessing Cpanel(0)
  7. Error 28 (on Phpmyadmin)(6)
  8. How To Make A View New Post Script?(5)
  9. Phpizabi Social Network Script(1)
  10. Phpbb3 - Error 28(5)
  11. Help Me _ Error Message: "could Not Retrieve Session Record"(2)
  12. Php Guest Online Script(2)
  13. Wordpress Error - Bytes Exausted(4)


 



- Lo-Fi Version Time is now: 25th July 2008 - 10:28 PM