Error in Array

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 30, 2012   (RSS)

Hi All,

In an Ajax implementation that sends out emails, I’m using the following code to create a list of the recipient's email addresses separated by a comma.
// Get email list of those members with notifications set to 1.

list($emailList,) = getRecords(array(
"tableName" => "accounts",
"where" => "notifications = 1",
));

foreach( $emailList as $record ) {

$emailList.= $record['email'] .",";

}

Problem is that when the list is created, the first email address has the word "Array" preceding it, IE:
Arraymyemail@bellsouth.net; jerry@jkwebdesigns.com
Any suggestions would be super.

Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Error in Array

By Jason - January 30, 2012

Hi Jerry,

The issue here is that your record set and your list string both use the variable name $emailList. On the first iteration of the loop, $emailList is an array.

Try this:

// Get email list of those members with notifications set to 1.

list($emailListRecords,) = getRecords(array(
"tableName" => "accounts",
"where" => "notifications = 1",
));

$emailList = "";

foreach( $emailListRecords as $record ) {

$emailList.= $record['email'] .",";

}


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/