Email Plugin (Eval)

stevelis

Member
Hi All
Just trying to get this to work with limited coding knowledge.
With the coding as shown, no errors are reported, but only the second query correctly sends an email in this coding.
Delete the second query, (in red text) no errors are reported and the first query send the emails
Details:
3 Lists - calendar, steward and adminemail
The calendar form has 4 databasejoin elements, 3 from stewards, steward1, steward2 and steward3 and one from adminemail, allocation.
All four are set to dropdown.

Any help in correcting the code would be appreciated

$db =& JFactory::getDBO();
$query = $db->getQuery(true);
$query = "SELECT `email` FROM `steward` WHERE `id` IN ('{calendar___steward1_raw}','{calendar___steward2_raw}','{calendar___steward3_raw}')";
$db->setQuery($query);
$results = $db->loadColumn();
$query = "SELECT `autoemail` FROM `adminemail` WHERE `id` IN ('{calendar___allocation_raw}')";
$db->setQuery($query);
$results = $db->loadColumn();
$email_list = implode(',',$results);
return $email_list;

Steve
 
You are "reloading" $result with the 2nd query,
try
...
$results1 = $db->loadColumn();
....
$results2 = $db->loadColumn();
$email_list = implode(',',array_merge($results1,results2));
...
 
troester thanks for the suggestion and I used the following code below, but unfortunately no emails sent.
have I written the coding as I should've?

db =& JFactory::getDBO();
$query = $db->getQuery(true);
$query = "SELECT `email` FROM `steward` WHERE `id` IN ('{calendar___steward1_raw}','{calendar___steward2_raw}','{calendar___steward3_raw}')";
$db->setQuery($query);
$results1 = $db->loadColumn();
$query = "SELECT `autoemail` FROM `adminemail` WHERE `id` IN ('{calendar___allocation_raw}')";
$db->setQuery($query);
$results2 = $db->loadColumn();
$email_list = implode(',',array_merge($results1,results2));
return $email_list;

I wasn't sure, but I also tried it with this slight change, $email_list = implode(',',array_merge($results1,$results2)); but it made no difference.

What is working fine, is one email form plugin with the the first query, and a second email form plugin with the second query.
However, I am not sure if this is the best practice because when you want to make changes etc, you have to do it twice.
 
before the return add :

Code:
echo "email list = $email_list";
exit;

does it show the correct list of emails?
Do you have php error reporting turn on, and are any errors generated?

-Rob
 
I wasn't sure, but I also tried it with this slight change, $email_list = implode(',',array_merge($results1,$results2)); but it made no difference.

It definitely needs to be $results2, leaving the $ off will cause a syntax error.

What I usually do in situations like this is start with the queries and the placeholder data, make sure they look sane.

So try dumping $query each time you set it, with ...

Code:
var_dump($query);exit;

... so put that after the first line where you set $query, make sure it looks OK, then move the dump to after the second time. To be really sure, try copying the query into phpMyAdmin (or whatever database utility you use) and run it by hand, make sure it returns what you expect.

If the queries look good, and don't have something like 'array' where one of your placeholder values should be, try dumping $results1 and $results2 as well.

This is much the same as Rob suggested for looking at the final array, I just prefer to use var_dump() rather than echo'ing, as it tells me the data type as well.

Oh, just to be clear ... when we talk about 'dumping' ... the 'exit' means your code will immediately terminate, and whatever you dumped will be shown in the browser. So you just submit a test form, and you'll get an anotherwise blank page, with whatever you dumped on it.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top