View Full Version : What is wrong with this script please?

03-01-2009, 05:53 PM
I have set up this script, and receive the error

Parse error: syntax error, unexpected '{' in /homepages/11/d272207702/htdocs/sendcvaction.php on line 139

Line 139 is two lines below the foreach line

$permitted = array('rec2reg1@googlemail.com', 'reg2reg2@googlemail.com', 'rec2reg3@googlemail.com', 'nathanjfuller@ntlworld.com');
$toaddresses = array('contact@rec2reg.co.uk');
$toaddresses = implode(',', $toAddresses);
$message = "You have recieved an application ";
if (!isset($_POST['sendTo'])) {

foreach ($_POST['sendTo'] as $item)

if (in_array($item, $permitted) {array_push($toaddresses, $item);

mail ($toadressess, 'Application', $message, 'FROM:Contact@example.co.uk);
mail ('contact@example.co.uk, 'An Application has been sent', 'An Application has been sent', 'FROM:Noreply@example.co.uk);

03-01-2009, 10:59 PM
I'm not a php expert but that if statement doesn't look right

it has an extra } try removing it.

When you specify and if statement you are testing if something is the case if that case is met then the code within the curly brackets will be executed for example

if (the sky is blue)
code will run

These curly braces should always be in pairs yours don't look to be and there's nothing in between them.

03-02-2009, 01:38 PM

Ricky is right

your conditional statement is wrong

if (!isset($_POST['sendTo'])) {

} else {

foreach ($_POST['sendTo'] as $item) ///<<< invalid foreach loop


if (in_array($item, $permitted) {

array_push($toaddresses, $item); ///<<< not sure what this is for?


///^ too many braces

im guessing a copy and paste job

03-02-2009, 04:10 PM
aye that's what i thought