Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    31
    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
    /* 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 */
    ?>

  • #2
    New Coder
    Join Date
    Jul 2005
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $success_sent_msg='{

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

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $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 ;

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    PHP Code:
    $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.

  • #5
    New Coder
    Join Date
    Jul 2005
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    New Coder
    Join Date
    Jul 2005
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by degsy
    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?
    PHP Code:
    $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;
    }
    Last edited by clubsoton; 02-16-2006 at 09:06 AM.

  • #7
    New Coder
    Join Date
    Jul 2005
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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;
    }

  • #8
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    $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;
    */ 

  • #9
    New Coder
    Join Date
    Jul 2005
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for that, thats really helpful.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •