Our client was getting this error:
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]

On line 334 it calls _get_civicrm_contactid_by_memberid($params['membershipID']) even on contribution pages that don't have a membership block. I added a check that $params['membershipID'] exists (see patch). It looks like that's the only place the function is called. If it's a donation page I figure civievent discount doesn't have anything to track here anyway.

CommentFileSizeAuthor
check-member.patch714 bytesnubeli

Comments

dharmatech’s picture

Assigned: Unassigned » dharmatech

Nubeli, can you provide a little more info on the configuration of the contribution page and steps to reproduce the error?

nubeli’s picture

Not sure what else I can provide. I believe that if you use a contribution page and if you *don't* have any memberships assigned then it will throw this error when going through the payment. For instance, on a donation page with no membership form.

dharmatech’s picture

Thanks, I'll see if I can duplicate.

dharmatech’s picture

Status: Active » Closed (cannot reproduce)

nubeli,

Maybe it's a bug in older versions of CiviCRM but I'm not able to duplicate this in 3.4.5. $params['contactID'] is always there, even if you're anonymous. The only time it's not there is when a 100% discount is applied to membership. Here's what I tried.

  • A contribution form that did not have membership.
  • Access contribution form as anonymous (and logged in user).
  • Submitted contribution without error.

If you can figure out a way to duplicate this, please post and we can reopen the issue.

nubeli’s picture

I can't replicate the error now - at the time it seemed like an obvious fix. It may be true then that there always is a contactID except for when there is a 100% discount (which is where I originally came across problem). So I'll let it rest unless it rears its head again.

It would make sense, however, to check for the existence of $params['membershipID'] before using it in the sql statement in the function _get_civicrm_contactid_by_memberid - "SELECT contact_id FROM civicrm_membership WHERE id = ". $mid. It may be unlikely but there may be some unknown combination that would cause the error (as I was initially able to trigger but can't replicate).

dharmatech’s picture

Yes, the next -dev release will include a check for $params['membershipID'].

ericdrogers’s picture

Status: Closed (cannot reproduce) » Active

I am also getting this on 6.x-1.x-dev. Any news on updated version?

dharmatech’s picture

Status: Active » Closed (cannot reproduce)

@ericdrogers, don't change the status to active unless you also assign it to yourself and fix it. Aside from a "me too" comment, what additional information can you provide that might help resolve the issue? We were not able to duplicate previously and the OP even had problems recreating it. If you figure out how to reliably reproduce it, we can re-open and fix it.