Answers.Body: <p>This error is still present in 5.32.2 but simple edit of one file as identified on <a href="https://github.com/civicrm/civicrm-core/pull/18948" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/pull/18948</a> temporarily fixes it</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-07T12:32:19.530Z
Answers.LastActivityDate: 2021-01-07T12:32:19.530Z
Answers.UserDisplayName: Jonathan Richardson
Answers.Body: <p>Welcome to CiviCRM Stack Exchange ... and congratulations on finding a bug!</p>
  <p>I've created an <a href="https://lab.civicrm.org/dev/core/-/issues/2172" rel="nofollow noreferrer">issue</a> and a <a href="https://github.com/civicrm/civicrm-core/pull/18948" rel="nofollow noreferrer">Pull Request (PR)</a>.  It is a very simple code change so if you can apply the change in the PR, test that it works for you and then leave a comment on the PR we should be able to get this resolved.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-10T02:52:09.513Z
Answers.Text: I've tested the edit made in the pull request and confirmed that it fixes the issue. The pull request has been reviewed and "approved" accordingly. Thank you for your help!
Answers.UserDisplayName: Brett Collins
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-09T21:46:16.953Z
Answers.LastActivityDate: 2020-11-09T21:46:16.953Z
Answers.UserDisplayName: Aidan
Body: <p><strong>System Info</strong></p>
  <blockquote>
  <ul>
  <li>Wordpress ver. 5.5.3</li>
  <li>SQL: 10.3.24-MariaDB-log-cll-lve - MariaDB Server</li>
  <li>Server:</li>
  </ul>
  <blockquote>
  <ul>
  <li>Cloudlinux 3.10.0-962.3.2.lve1.5.38.el7.x86_64</li>
  <li>Apache 2.4.46</li>
  <li>PHP 7.4</li>
  </ul>
  </blockquote>
  </blockquote>
  <p>Issue is in <strong>both</strong> <strong>Civi ver 5.31.0 and 5.29</strong> - persisted past update/upgrade.</p>
  <p>Issue is that attempting to search for a respondent to reserve in civiCampaign creates a <code>DB Error: Syntax error</code></p>
  <p>The log states:</p>
  <p>Nov 07 14:41:58  [debug] $backTrace = #0 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(205): CRM_Core_Error::backtrace(&quot;backTrace&quot;, TRUE)</p>
  <pre><code>#1 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error))
  
  #2 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB.php(997): PEAR_Error-&gt;__construct(&quot;DB Error: syntax error&quot;, -2, 16, (Array:2), &quot;\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...&quot;)
  
  #3 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error-&gt;__construct(-2, 16, (Array:2), &quot;\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...&quot;)
  
  #4 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR::_raiseError(Object(DB_mysqli), NULL, -2, 16, (Array:2), &quot;\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...&quot;, &quot;DB_Error&quot;, TRUE)
  
  #5 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php(1928): PEAR-&gt;__call(&quot;raiseError&quot;, (Array:7))
  
  #6 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php(936): DB_common-&gt;raiseError(-2, NULL, NULL, &quot;\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...&quot;, &quot;1064 ** You have an error in your SQL syntax; check the manual that correspon...&quot;)
  
  #7 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php(406): DB_mysqli-&gt;mysqliRaiseError()
  
  #8 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php(1234): DB_mysqli-&gt;simpleQuery(&quot;\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...&quot;)
  
  #9 /path/to/site//wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2696): DB_common-&gt;query(&quot;\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...&quot;)
  
  #10 /path/to/site//wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1829): DB_DataObject-&gt;_query(&quot;\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...&quot;)
  
  #11 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(457): DB_DataObject-&gt;query(&quot;\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...&quot;)
  
  #12 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1563): CRM_Core_DAO-&gt;query(&quot;\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...&quot;, TRUE)
  
  #13 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/PrevNextCache/Sql.php(43): CRM_Core_DAO::executeQuery(&quot;\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...&quot;, (Array:1), FALSE)
  
  #14 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Campaign/Selector/Search.php(274): CRM_Core_PrevNextCache_Sql-&gt;fillWithSql(&quot;civicrm search 2fedcb1a2b91b5337b15b83d001a4da5e9fdb2c76fbcc44ca3c12ce5d6dc9f...&quot;, &quot;\n      SELECT %1, contact_a.id, contact_a.display_name\nFROM  FROM civicrm_c...&quot;, (Array:1))
  
  #15 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Campaign/Selector/Search.php(244): CRM_Campaign_Selector_Search-&gt;buildPrevNextCache(Object(CRM_Utils_Sort))
  
  #16 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Selector/Controller.php(402): CRM_Campaign_Selector_Search-&gt;getRows(4, 0, 50, Object(CRM_Utils_Sort), 1, NULL)
  
  #17 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Selector/Controller.php(324): CRM_Core_Selector_Controller-&gt;getRows(Object(CRM_Core_Selector_Controller))
  
  #18 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Campaign/Form/Search.php(287): CRM_Core_Selector_Controller-&gt;run()
  
  #19 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(514): CRM_Campaign_Form_Search-&gt;postProcess()
  
  #20 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Refresh.php(57): CRM_Core_Form-&gt;mainProcess()
  
  #21 /path/to/site//wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Refresh-&gt;perform(Object(CRM_Campaign_Form_Search), &quot;refresh&quot;)
  
  #22 /path/to/site//wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller-&gt;handle(Object(CRM_Campaign_Form_Search), &quot;refresh&quot;)
  
  #23 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(347): HTML_QuickForm_Page-&gt;handle(&quot;refresh&quot;)
  
  #24 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(312): CRM_Core_Controller-&gt;run((Array:3), NULL)
  
  #25 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(68): CRM_Core_Invoke::runItem((Array:15))
  
  #26 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:3))
  
  #27 /path/to/site//wp-content/plugins/civicrm/civicrm.php(1644): CRM_Core_Invoke::invoke((Array:3))
  
  #28 /path/to/site//wp-includes/class-wp-hook.php(287): CiviCRM_For_WordPress-&gt;invoke(&quot;&quot;)
  
  #29 /path/to/site//wp-includes/class-wp-hook.php(311): WP_Hook-&gt;apply_filters(&quot;&quot;, (Array:1))
  
  #30 /path/to/site//wp-includes/plugin.php(478): WP_Hook-&gt;do_action((Array:1))
  
  #31 /path/to/site//wp-admin/admin.php(259): do_action(&quot;toplevel_page_CiviCRM&quot;)
  
  #32 {main}
  
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-11-09T18:34:49.417Z
Comments.Text: Do you get errors trying to do any other contact searches?  Does clearing the CiviCRM caches help at all?
Comments.UserDisplayName: Aidan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-11-09T19:37:12.220Z
Comments.Text: @Aidan The default "find contact" search works, and the advance contact search works as well.
Comments.UserDisplayName: Brett Collins
Tags: <wordpress><database><civicampaign><mariadb>
Title: "Find Respondents to Reserve" - DB Error: syntax error
ThreadText: # "Find Respondents to Reserve" - DB Error: syntax error
  
  (Asked by: username_0 on 2020-11-07)
  
  **System Info**
  
  > * Wordpress ver. 5.5.3
  > * SQL: 10.3.24-MariaDB-log-cll-lve - MariaDB Server
  > * Server:
  >
  > > * Cloudlinux 3.10.0-962.3.2.lve1.5.38.el7.x86\_64
  > > * Apache 2.4.46
  > > * PHP 7.4
  
  Issue is in **both** **Civi ver 5.31.0 and 5.29** - persisted past update/upgrade.
  
  Issue is that attempting to search for a respondent to reserve in civiCampaign creates a `DB Error: Syntax error`
  
  The log states:
  
  Nov 07 14:41:58 [debug] $backTrace = #0 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(205): CRM\_Core\_Error::backtrace("backTrace", TRUE)
  
  ```
  #1 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error))
  
  #2 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB.php(997): PEAR_Error->__construct("DB Error: syntax error", -2, 16, (Array:2), "\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...")
  
  #3 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-2, 16, (Array:2), "\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...")
  
  #4 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR::_raiseError(Object(DB_mysqli), NULL, -2, 16, (Array:2), "\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...", "DB_Error", TRUE)
  
  #5 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php(1928): PEAR->__call("raiseError", (Array:7))
  
  #6 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php(936): DB_common->raiseError(-2, NULL, NULL, "\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...", "1064 ** You have an error in your SQL syntax; check the manual that correspon...")
  
  #7 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php(406): DB_mysqli->mysqliRaiseError()
  
  #8 /path/to/site//wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php(1234): DB_mysqli->simpleQuery("\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...")
  
  #9 /path/to/site//wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2696): DB_common->query("\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...")
  
  #10 /path/to/site//wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1829): DB_DataObject->_query("\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...")
  
  #11 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(457): DB_DataObject->query("\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...")
  
  #12 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1563): CRM_Core_DAO->query("\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...", TRUE)
  
  #13 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/PrevNextCache/Sql.php(43): CRM_Core_DAO::executeQuery("\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\n\n      SE...", (Array:1), FALSE)
  
  #14 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Campaign/Selector/Search.php(274): CRM_Core_PrevNextCache_Sql->fillWithSql("civicrm search 2fedcb1a2b91b5337b15b83d001a4da5e9fdb2c76fbcc44ca3c12ce5d6dc9f...", "\n      SELECT %1, contact_a.id, contact_a.display_name\nFROM  FROM civicrm_c...", (Array:1))
  
  #15 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Campaign/Selector/Search.php(244): CRM_Campaign_Selector_Search->buildPrevNextCache(Object(CRM_Utils_Sort))
  
  #16 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Selector/Controller.php(402): CRM_Campaign_Selector_Search->getRows(4, 0, 50, Object(CRM_Utils_Sort), 1, NULL)
  
  #17 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Selector/Controller.php(324): CRM_Core_Selector_Controller->getRows(Object(CRM_Core_Selector_Controller))
  
  #18 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Campaign/Form/Search.php(287): CRM_Core_Selector_Controller->run()
  
  #19 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(514): CRM_Campaign_Form_Search->postProcess()
  
  #20 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Refresh.php(57): CRM_Core_Form->mainProcess()
  
  #21 /path/to/site//wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Refresh->perform(Object(CRM_Campaign_Form_Search), "refresh")
  
  #22 /path/to/site//wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Campaign_Form_Search), "refresh")
  
  #23 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(347): HTML_QuickForm_Page->handle("refresh")
  
  #24 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(312): CRM_Core_Controller->run((Array:3), NULL)
  
  #25 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(68): CRM_Core_Invoke::runItem((Array:15))
  
  #26 /path/to/site//wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:3))
  
  #27 /path/to/site//wp-content/plugins/civicrm/civicrm.php(1644): CRM_Core_Invoke::invoke((Array:3))
  
  #28 /path/to/site//wp-includes/class-wp-hook.php(287): CiviCRM_For_WordPress->invoke("")
  
  #29 /path/to/site//wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters("", (Array:1))
  
  #30 /path/to/site//wp-includes/plugin.php(478): WP_Hook->do_action((Array:1))
  
  #31 /path/to/site//wp-admin/admin.php(259): do_action("toplevel_page_CiviCRM")
  
  #32 {main}
  
  ```
  
  **Tags:** wordpress, database, civicampaign, mariadb
  
  > **Comments:**
  > **username_1**: Do you get errors trying to do any other contact searches?  Does clearing the CiviCRM caches help at all?  
  > **username_0**: @username_1 The default "find contact" search works, and the advance contact search works as well.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-11-09. Score: 3 | Accepted answer
  
  Welcome to CiviCRM Stack Exchange ... and congratulations on finding a bug!
  
  I've created an [issue](https://lab.civicrm.org/dev/core/-/issues/2172) and a [Pull Request (PR)](https://github.com/civicrm/civicrm-core/pull/18948). It is a very simple code change so if you can apply the change in the PR, test that it works for you and then leave a comment on the PR we should be able to get this resolved.
  
  > **Comments:**
  > **username_0**: I've tested the edit made in the pull request and confirmed that it fixes the issue. The pull request has been reviewed and "approved" accordingly. Thank you for your help!  
  
  ---
  
  ### Answer by username_2 on 2021-01-07. Score: 0
  
  This error is still present in 5.32.2 but simple edit of one file as identified on <https://github.com/civicrm/civicrm-core/pull/18948> temporarily fixes it
  
  
  ---
  
  