I have a regular contribution page, so that people can donate to a cause, at the end of a successful location they get this code on the thankyou page.

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 '' at line 1, 1064
Additional Details:
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] => SELECT contact_id FROM civicrm_membership WHERE id =  [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 '' at line 1]
    [type] => DB_Error
    [user_info] => SELECT contact_id FROM civicrm_membership WHERE id =  [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 '' 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_id FROM civicrm_membership WHERE id =  [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 '' at line 1]"]
)

this is the backtrace

backTrace
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 159
, handle, 
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/PEAR.php, call_user_func, 931
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/DB.php, PEAR_Error, 968
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/PEAR.php, DB_Error, 564
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/DB/common.php, raiseError, 1903
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/DB/mysql.php, raiseError, 898
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/DB/mysql.php, mysqlRaiseError, 327
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/DB/common.php, simpleQuery, 1216
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/DB/DataObject.php, query, 2424
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/DB/DataObject.php, _query, 1610
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Core/DAO.php, query, 152
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Core/DAO.php, query, 879
/home/site/public_html/www.com/modules/civievent_discount/civievent_discount.module, executeQuery, 680
/home/site/public_html/www.com/modules/civievent_discount/civievent_discount.module, _get_civicrm_contactid_by_memberid, 337
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Utils/Hook/Drupal.php, civievent_discount_civicrm_postProcess, 53
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Utils/Hook.php(145) : eval()'d code, invoke, 1
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Utils/Hook.php, eval, 145
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Core/Form.php, postProcess, 265
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Core/Form.php, postProcessHook, 252
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Core/StateMachine.php, mainProcess, 167
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php, perform, 64
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php, perform, 203
/home/site/public_html/www.com/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php, handle, 103
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Core/Controller.php, handle, 284
/home/site/public_html/www.com/sites/all/modules/civicrm/CRM/Core/Invoke.php, run, 223
/home/site/public_html/www.com/sites/all/modules/civicrm/drupal/civicrm.module, invoke, 360
, civicrm_invoke, 
/home/site/public_html/www.com/includes/menu.inc, call_user_func_array, 349
/home/site/public_html/www.com/index.php, menu_execute_active_handler, 17

Comments

dharmatech’s picture

Please provide the version of CiviCRM you're using and specifics on how your contribution page is configured. This code block should only be called if you're using membership, but for some reason the membership id is not available.

bdanza’s picture

I am using 3.4.6

it is configured to take company contributions, with a simple new company form and the individual from.
the payment processor is paypal pro

GregoryHeller’s picture

I'm seeing this on 3.4.7. plain vanilla contribution page, no membership section enabled. We do have civievent discount module configured to allow for discounts on memberships. we do not see the error on contribution pages where the membership section is enabled. I thought that the problem might have related to having some discount codes that work on memberships (rather than on events), but after removing those codes (well removing the membership discounting option from those codes) I still got the error.

The contribution page is setup to use other amounts only ( no price set, or price levels), payment processor is authorize.net, pay later is not enabled, Look for me on IRC if you have any questions.

UPDATE: When the membership section is enabled on this donation page, but the minimum contribution for membership is greater than the maximum contribution the membership page allows, the error occurs (the user is forced to choose the "no thank you" option in the membership section.

So it would seem that this error occurs whenever a contribution is made that does not involve a membership (perhaps it only starts after you have created a discount code that applies to memberships, and then there is no backing down).

dharmatech’s picture

Assigned: Unassigned » dharmatech
Status: Active » Fixed

Thanks @GregoryHeller for the clear details on how to reproduce and @bdanza for the backtrace. Super helpful. Fixed in latest -dev release. You may need to wait 24 hours for the next release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.