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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with error message.

    Hi all, I'm new to php and this forum and have a question with a form script I'm using and maybe someone could help me with or point in the right direction. I've searched other posts and based on what I've found and read I believe I've made sure there were no white spaces etc. The error message is as follows:
    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/bottleca/public_html/forms/battleofbrands/processor.php on line 9

    Here is the file I'm trying to set up (i've highlighted the code that seems to be causing me the grief):

    <?php

    $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

    session_start();
    if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) {
    mail("help@bottlecaplure.com","Battle of the Brands Question","Form data:
    " . $mail_message .= "Form Submitted by IP Address: ".$_SERVER['REMOTE_ADDR']."\n" . "
    if (ereg(^([a-zA-Z0-9_-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([a-zA-Z0-9-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$, $_POST['email'])) {
    echo "<br>Please enter a valid e-mail address.";
    }


    Question: " . $_POST['field_1'] . "
    Your email address: " . $_POST['field_2'] . "


    ");

    include("confirm.html");
    }
    else {
    echo "Invalid Captcha String.";
    }

    ?>

    Basshook

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    You need to move that if() switch outside of the string. Set it to a temporary variable, and include that variable in the string.
    Something like:
    PHP Code:
    $temp '';
    if (
    ereg('^([a-zA-Z0-9_-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([a-zA-Z0-9-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)'$_POST['email'])) {
        
    $temp "<br>Please enter a valid e-mail address.";
    }
    mail("help@bottlecaplure.com","Battle of the Brands Question","Form data:
    $mail_message "Form Submitted by IP Address: ".$_SERVER['REMOTE_ADDR']."\n
    $temp

    Question: " 
    $_POST['field_1'] . "
    Your email address: " 
    $_POST['field_2'] . "


    "
    ); 
    Not tested. Just an example.
    Last edited by Inigoesdr; 03-08-2008 at 08:21 AM.

  • #3
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your quick reply, however after changing code, I now get this error message:
    Parse error: syntax error, unexpected '^', expecting ')' in /home/bottleca/public_html/forms/battleofbrands/processor.php on line 8

    I tried removing the text symbol it defined but that didn't work either.
    Basshook

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Yeah, you need to wrap your regex in quotes. See my edited post for example.


  •  

    Posting Permissions

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