Rahul Dev Posted January 23, 2011 Share Posted January 23, 2011 Hello, i need to send emails to users according to the category they have selected everything works fine except for the mail function which tells me that i cannot parse an array variable. the error code is: Warning: mail() expects parameter 1 to be string, array given in C:\wamp\www\newsletter.php on line 25 can any1 tell me how i can send the mail so that it accepts that variable? my code is: <?php $db_hostname="localhost"; $db_username="root"; $db_password=""; $db = mysql_connect($db_hostname,$db_username,$db_password); if (!$db) { die("Could not connect: " . mysql_error()); } mysql_select_db("newsletter", $db); if (isset($_POST['categories'])) { //make the checkmarks with name categories[] foreach ($_POST['categories'] as $cat) { $email_query = mysql_query("SELECT email FROM members WHERE `category` = '" . $cat . "'"); if (mysql_num_rows($email_query)) { while ($email = mysql_fetch_array($email_query)) { ini_set('SMTP','smtp.gmail.com'); if (mail($email, 'Subject','Message Goes Here', "From: <[email protected]>")) { echo "Message Sent"; } else { echo "Message Not Sent"; } }//end while }// end if } } ?> Link to comment https://forums.phpfreaks.com/topic/225410-sending-mail-array-problem/ Share on other sites More sharing options...
Pikachu2000 Posted January 23, 2011 Share Posted January 23, 2011 if (mail($email['email'], . . . etc. Link to comment https://forums.phpfreaks.com/topic/225410-sending-mail-array-problem/#findComment-1164027 Share on other sites More sharing options...
Rahul Dev Posted January 23, 2011 Author Share Posted January 23, 2011 if (mail($email['email'], . . . etc. Thanx for the help! its ok now Link to comment https://forums.phpfreaks.com/topic/225410-sending-mail-array-problem/#findComment-1164029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.