CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • MySQL Error in 3.0.4
Pages: [1]

Author Topic: MySQL Error in 3.0.4  (Read 1530 times)

GingerFeet

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 4
  • CiviCRM version: 3.4.6 / 3.4.7
  • CMS version: Drupal 6.22
  • MySQL version: 5.1
  • PHP version: 5.3.6
MySQL Error in 3.0.4
February 14, 2010, 02:51:25 pm
Hi,

I'm getting a MySQL Error.
Did an upgrade from Drupal5/CiviCRM2.0.7 -> Drupal6/CiviCRM3.0.4
Everything is working well except for the error.

This is probably not the 'Deceased' issue, because 'Deceased' is in the _membership_status table, and is active.

The site has a custom form. When the 'continue' button is clicked to submit the form, the MySQL error appears. Even though the error appears, the data gets written correctly to the db.

Any ideas?

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 ( civicrm_membership.contact_id = 4193 ) AND ( civicrm_membership.membe' at line 4, 1064

Return to home page.

Error Details:

Array
(
    [callback] => Array
        (
           
  • => CRM_Core_Error
  • [1] => handle
            )

       
Code: [Select]
=> -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] => SELECT *
 FROM civicrm_membership
 
 WHERE ( status_id !=  )  AND (  civicrm_membership.contact_id = 4193 ) AND (  civicrm_membership.membership_type_id = 1 )
 
 
 ORDER BY start_date DESC 
 [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 (  civicrm_membership.contact_id = 4193 ) AND (  civicrm_membership.membe' at line 4]
    [type] => DB_Error
    [user_info] => SELECT *
 FROM civicrm_membership
 
 WHERE ( status_id !=  )  AND (  civicrm_membership.contact_id = 4193 ) AND (  civicrm_membership.membership_type_id = 1 )
 
 
 ORDER BY start_date DESC 
 [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 (  civicrm_membership.contact_id = 4193 ) AND (  civicrm_membership.membe' at line 4]
    [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT *
 FROM civicrm_membership
 
 WHERE ( status_id !=  )  AND (  civicrm_membership.contact_id = 4193 ) AND (  civicrm_membership.membership_type_id = 1 )
 
 
 ORDER BY start_date DESC 
 [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 (  civicrm_membership.contact_id = 4193 ) AND (  civicrm_membership.membe' at line 4]"]
)

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: MySQL Error in 3.0.4
February 15, 2010, 09:10:20 am
Jake - Pretty sure some expected status is missing in membership rules. Best bet is to enable backtrace so you can see what function is invoking the query and get a bet idea of the intended 'status exclusion'.
Protect your investment in CiviCRM by  becoming a Member!

GingerFeet

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 4
  • CiviCRM version: 3.4.6 / 3.4.7
  • CMS version: Drupal 6.22
  • MySQL version: 5.1
  • PHP version: 5.3.6
Re: MySQL Error in 3.0.4
February 20, 2010, 05:27:27 pm
I was unable to figure out the backTrace. I was able to get CiviCRM to spit out the offending query.
Not sure how you can have a status_id that isn't equal. Isn't equal to what?

Any ideas?


 query = SELECT * FROM civicrm_membership
         WHERE ( status_id != )
         AND ( civicrm_membership.contact_id = 4199 )
         AND ( civicrm_membership.membership_type_id = 1 )
         ORDER BY start_date DESC



backTrace

/sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 146
, handle,
/sites/all/modules/civicrm/packages/PEAR.php, call_user_func, 912
/sites/all/modules/civicrm/packages/DB.php, PEAR_Error, 966
/sites/all/modules/civicrm/packages/PEAR.php, DB_Error, 574
/sites/all/modules/civicrm/packages/DB/common.php, raiseError, 1905
/sites/all/modules/civicrm/packages/DB/mysql.php, raiseError, 898
/sites/all/modules/civicrm/packages/DB/mysql.php, mysqlRaiseError, 327
/sites/all/modules/civicrm/packages/DB/common.php, simpleQuery, 1218
/sites/all/modules/civicrm/packages/DB/DataObject.php,
query, 2394
/sites/all/modules/civicrm/packages/DB/DataObject.php, _query, 442
/sites/all/modules/civicrm/CRM/Member/BAO/Membership.php, find, 701
/sites/all/modules/civicrm/CRM/Member/BAO/Membership.php, getContactMembership, 1117
/sites/all/modules/civicrm/CRM/Member/BAO/Membership.php, renewMembership, 1019
/sites/all/modules/civicrm/CRM/Contribute/Form/Contribution/Confirm.php, postProcessMembership, 514
/sites/all/modules/civicrm/CRM/Core/Form.php, postProcess, 248
/sites/all/modules/civicrm/CRM/Core/StateMachine.php, mainProcess, 166
/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php, perform, 63
/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php, perform, 203
/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php, handle, 103
/sites/all/modules/civicrm/CRM/Core/Controller.php, handle, 249
/sites/all/modules/civicrm/CRM/Core/Invoke.php, run, 209
/sites/all/modules/civicrm/drupal/civicrm.module, invoke, 333
, civicrm_invoke,
/includes/menu.inc, call_user_func_array, 348
/index.php, menu_execute_active_handler, 18

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: MySQL Error in 3.0.4
February 21, 2010, 09:42:24 am
Jake - Looks to me like the missing status is 'Pending'. This s/b a reserved membership status in your DB :

Code: [Select]
        //avoid pending membership as current memebrship: CRM-3027
        require_once 'CRM/Member/PseudoConstant.php';       
        $pendingStatusId = array_search( 'Pending', CRM_Member_PseudoConstant::membershipStatus( ) );
        $dao->whereAdd( "status_id != $pendingStatusId" );

Check the demo for the correct config for Pending membership status:
http://drupal.demo.civicrm.org/civicrm/admin/member/membershipStatus&reset=1

If you went through 'documented' upgrade sequence and didn't get any errors AND the Pending status wasn't added as it should have been - please file a bug report in the Issue Tracker describing the upgrade sequence - we'll add a check to the upgrade script going forward to make sure other sites don't hit this.
Protect your investment in CiviCRM by  becoming a Member!

GingerFeet

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 4
  • CiviCRM version: 3.4.6 / 3.4.7
  • CMS version: Drupal 6.22
  • MySQL version: 5.1
  • PHP version: 5.3.6
Re: MySQL Error in 3.0.4
February 22, 2010, 11:11:03 am
OK.

And it's my bad. Pending was the issue. It was there but turned off.

But, for anyone who is searching the forums for the info --

Membership status rules:
Deceased and Pending are required.  If your version of CiviCRM allows you to enable/disable them, make sure they are enabled. And if your version of CiviCRM allows you to delete them, well, you will just have to recreate them.

Are there any other required Membership status rules?

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: MySQL Error in 3.0.4
February 22, 2010, 03:50:03 pm
Our bad too, for not 'protecting' them earlier. They are reserved and can't be deleted or modified in 3.1.
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • MySQL Error in 3.0.4

This forum was archived on 2017-11-26.