Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Error in Array

 

 


gkornbluth
Veteran

Jan 28, 2012, 9:13 AM

Post #1 of 3 (93 views)
Shortcut
Error in Array Can't Post

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.

Code
 // 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:

Code
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!
http://www.thecmsbcookbook.com


Jason
Staff / Moderator


Jan 30, 2012, 10:10 AM

Post #2 of 3 (86 views)
Shortcut
Re: [gkornbluth] Error in Array [In reply to] Can't Post

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:


Code
 // 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 - Programmer 
interactivetools.com

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


gkornbluth
Veteran

Jan 30, 2012, 3:46 PM

Post #3 of 3 (85 views)
Shortcut
Re: [Jason] Error in Array [In reply to] Can't Post

Oops.

Sometimes I can't see the forest because the trees seem to get in the way.

Thanks Jason,

Jerry