...

View Full Version : Need help with error message.



basshook
03-08-2008, 04:49 AM
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

Inigoesdr
03-08-2008, 05:03 AM
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:

$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.

basshook
03-08-2008, 06:06 AM
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

Inigoesdr
03-08-2008, 08:20 AM
Yeah, you need to wrap your regex in quotes. See my edited post for example.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum