Jump to content

foreach problem


mforan

Recommended Posts

Hi there, im having bit of a problem with this foreach.... as far as i can see i think its right? no doubt something is horribly wrong... lol. anyone have any idea?

 

(post email would be for example "[email protected], [email protected]")

((which makes sense since this SHUD be arrayable???))

<?php
$emails = preg_replace("[^a-z0-9\@\.\_\-]", "", $_POST["email"]);
$emailArray = explode(",",$emails);
	foreach($emailArray As $emails[0]){
	$query = "SELECT count(email) FROM buddyp WHERE email='$emails[0]'";
	$result = mysql_query($query) or die("Error: ".mysql_error());
	$emailc = mysql_fetch_array($result, MYSQL_NUM);
		if ($emailc[0] == 0) {
		$query = "INSERT INTO buddyp SET email='$emails[0]',day='".time()."'";
		mysql_query($query) or die("Error: ".mysql_error());
		// message
		$message = 'EMAIL CONTENTS';
		// To send HTML mail, the Content-type header must be set
		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		// Additional headers
		$headers .= 'From: Ambroid <[email protected]>' . "\r\n";
		// Mail it
		mail($emails[0], "AMBROID - The War Game", $message, $headers);	
		$exc = "Emails were sent to: $emails[0]";	
		} else {
		$exc = "ERROR: You cannot invite the same person to the game within a 3 day period!";
		}
	}
?>

Link to comment
https://forums.phpfreaks.com/topic/210382-foreach-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.