[SOLVED] Parse error: syntax error, unexpected ','

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
squire40
Forum Newbie
Posts: 2
Joined: Mon May 07, 2007 1:34 pm

[SOLVED] Parse error: syntax error, unexpected ','

Post by squire40 »

Jcart | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi.  I'm using swiftmailer to send a (non-spam) bulk email, and I'm getting the following error: Parse error: syntax error, unexpected ','

Here is the code:

Code: Select all

foreach($_REQUEST['emailTo'] as $val)
{
	$temp = explode("|",$val);
	$recipients->addTo($temp[1], $temp[0]);	
}

	if ($swift->batchSend(($message, $recipients, $GLOBAL['from_email']))
	{
		echo "Message sent";
		$isError = false;
	}
	else
	{
		echo "Message failed to send";
		$isError = true;
	}
I have verified that the above values for name and email address are populated correctly. Has anyone else had a similar error? Any ideas? Please forgive the syntax of my post as I am a noob to this forum. Thanks.


Jcart | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

You have 3 opening brackets on your swift batchSend if statement line and only 2 closing brackets. If you have viewed this code in any editor worth it's salt you could've easily spotted it via the syntax highlighting.
squire40
Forum Newbie
Posts: 2
Joined: Mon May 07, 2007 1:34 pm

Post by squire40 »

What an oversight!! I guess it comes from staring at the same code for too long. Thanks for the reply!!
Post Reply