Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Critical
-
Resolution: Cannot Reproduce
-
Affects Version/s: 3.1.3
-
Fix Version/s: 3.2
-
Component/s: Core CiviCRM
-
Labels:None
Description
When I try to send an email to one or more contacts using the "Send email" action, I use a template that starts out "Dear
{first_name}. ( The rest is just plain text. )
I get the following error:
--------------------------------------------------------------------------------------------------------------
Sorry. A non-recoverable error has occurred.
DB Error: syntax error
Database Error Code: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ) AND contact_a.is_deceased = 0 AND LOWER(civicrm_email.on_hold) = '0' ) LIM' at line 1, 1064
Return to home page.
Error Details:
Array
(
[callback] => Array
(
[0] => CRM_Core_Error
[1] => handle
)
[code] => -2
[message] => DB Error: syntax error
[mode] => 16
[debug_info] => SELECT contact_a.id as contact_id, contact_a.first_name as `first_name`, contact_a.is_deceased as `is_deceased`, civicrm_email.id as email_id, civicrm_email.on_hold as `on_hold` FROM civicrm_contact contact_a LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1) WHERE ( ( contact_a.id IN (1,3, ) ) AND contact_a.is_deceased = 0 AND LOWER(civicrm_email.on_hold) = '0' ) LIMIT 0, 3 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ) AND contact_a.is_deceased = 0 AND LOWER(civicrm_email.on_hold) = '0' ) LIM' at line 1]
[type] => DB_Error
[user_info] => SELECT contact_a.id as contact_id, contact_a.first_name as `first_name`, contact_a.is_deceased as `is_deceased`, civicrm_email.id as email_id, civicrm_email.on_hold as `on_hold` FROM civicrm_contact contact_a LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1) WHERE ( ( contact_a.id IN (1,3, ) ) AND contact_a.is_deceased = 0 AND LOWER(civicrm_email.on_hold) = '0' ) LIMIT 0, 3 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ) AND contact_a.is_deceased = 0 AND LOWER(civicrm_email.on_hold) = '0' ) LIM' at line 1]
[to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT contact_a.id as contact_id, contact_a.first_name as `first_name`, contact_a.is_deceased as `is_deceased`, civicrm_email.id as email_id, civicrm_email.on_hold as `on_hold` FROM civicrm_contact contact_a LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1) WHERE ( ( contact_a.id IN (1,3, ) ) AND contact_a.is_deceased = 0 AND LOWER(civicrm_email.on_hold) = '0' ) LIMIT 0, 3 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ) AND contact_a.is_deceased = 0 AND LOWER(civicrm_email.on_hold) = '0' ) LIM' at line 1]"]
)
------------------------------------------------------------------------------
It appears the problem is that the spot "WHERE ( ( contact_a.id IN (1,3, ) )" always has a trailing comma.
This happens when I use the "search" email action as well as using the action from the contact summary screen. It also happens when I use ANY token. If there are no tokens, then the email function works just fine.