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 »
  • Using CiviSMS »
  • SMS API Parameters
Pages: [1]

Author Topic: SMS API Parameters  (Read 2510 times)

Toeterniettoe

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: 4.6.alpha4
  • CMS version: Drupal 7.34
  • MySQL version: 5.5.41
  • PHP version: 5.3.25
SMS API Parameters
October 13, 2012, 11:31:29 am
Hi,

I've configured the SMS API in CiviCRM, but I keep getting a "DB Error: syntax error", as posted in http://forum.civicrm.org/index.php/topic,25231.0.html.

I enabled debugging and got this:

Code: [Select]
Database foutcode: 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_phone.phone IS NOT NULL AND ' at line 23, 1064
Aanvullende gegevens:
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] => REPLACE INTO       I_11 (phone_id, contact_id)

                    SELECT DISTINCT     civicrm_phone.id as phone_id,
                                        civicrm_contact.id as contact_id
                    FROM                civicrm_phone
                    INNER JOIN          civicrm_contact
                            ON          civicrm_phone.contact_id = civicrm_contact.id
                    INNER JOIN          civicrm_group_contact
                            ON          civicrm_contact.id = civicrm_group_contact.contact_id
                    INNER JOIN          civicrm_mailing_group
                            ON          civicrm_group_contact.group_id = civicrm_mailing_group.entity_id
                                AND     civicrm_mailing_group.entity_table = 'civicrm_group'
                    LEFT JOIN           X_11
                            ON          civicrm_contact.id = X_11.contact_id
                    WHERE
                                       (civicrm_mailing_group.group_type = 'Include')
                        AND             civicrm_mailing_group.search_id IS NULL
                        AND             civicrm_group_contact.status = 'Added'
                        AND             civicrm_contact.do_not_sms = 0
                        AND             civicrm_contact.is_opt_out = 0
                        AND             civicrm_contact.is_deceased = 0
                        AND             civicrm_phone.phone_type_id =
                        AND             civicrm_phone.phone IS NOT NULL
                        AND             civicrm_phone.phone != ''
                        AND             civicrm_mailing_group.mailing_id = 11
                        AND             X_11.contact_id IS null [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_phone.phone IS NOT NULL
                        AND     ' at line 23]
    [type] => DB_Error
    [user_info] => REPLACE INTO       I_11 (phone_id, contact_id)

                    SELECT DISTINCT     civicrm_phone.id as phone_id,
                                        civicrm_contact.id as contact_id
                    FROM                civicrm_phone
                    INNER JOIN          civicrm_contact
                            ON          civicrm_phone.contact_id = civicrm_contact.id
                    INNER JOIN          civicrm_group_contact
                            ON          civicrm_contact.id = civicrm_group_contact.contact_id
                    INNER JOIN          civicrm_mailing_group
                            ON          civicrm_group_contact.group_id = civicrm_mailing_group.entity_id
                                AND     civicrm_mailing_group.entity_table = 'civicrm_group'
                    LEFT JOIN           X_11
                            ON          civicrm_contact.id = X_11.contact_id
                    WHERE
                                       (civicrm_mailing_group.group_type = 'Include')
                        AND             civicrm_mailing_group.search_id IS NULL
                        AND             civicrm_group_contact.status = 'Added'
                        AND             civicrm_contact.do_not_sms = 0
                        AND             civicrm_contact.is_opt_out = 0
                        AND             civicrm_contact.is_deceased = 0
                        AND             civicrm_phone.phone_type_id =
                        AND             civicrm_phone.phone IS NOT NULL
                        AND             civicrm_phone.phone != ''
                        AND             civicrm_mailing_group.mailing_id = 11
                        AND             X_11.contact_id IS null [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_phone.phone IS NOT NULL
                        AND     ' at line 23]
    [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="REPLACE INTO       I_11 (phone_id, contact_id)

                    SELECT DISTINCT     civicrm_phone.id as phone_id,
                                        civicrm_contact.id as contact_id
                    FROM                civicrm_phone
                    INNER JOIN          civicrm_contact
                            ON          civicrm_phone.contact_id = civicrm_contact.id
                    INNER JOIN          civicrm_group_contact
                            ON          civicrm_contact.id = civicrm_group_contact.contact_id
                    INNER JOIN          civicrm_mailing_group
                            ON          civicrm_group_contact.group_id = civicrm_mailing_group.entity_id
                                AND     civicrm_mailing_group.entity_table = 'civicrm_group'
                    LEFT JOIN           X_11
                            ON          civicrm_contact.id = X_11.contact_id
                    WHERE
                                       (civicrm_mailing_group.group_type = 'Include')
                        AND             civicrm_mailing_group.search_id IS NULL
                        AND             civicrm_group_contact.status = 'Added'
                        AND             civicrm_contact.do_not_sms = 0
                        AND             civicrm_contact.is_opt_out = 0
                        AND             civicrm_contact.is_deceased = 0
                        AND             civicrm_phone.phone_type_id =
                        AND             civicrm_phone.phone IS NOT NULL
                        AND             civicrm_phone.phone != ''
                        AND             civicrm_mailing_group.mailing_id = 11
                        AND             X_11.contact_id IS null [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_phone.phone IS NOT NULL
                        AND     ' at line 23]"]
)

What can be causing this error?

Gregory

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: SMS API Parameters
October 14, 2012, 05:20:31 am
Gregory,

Just looking at the 2 lines ...
Quote
                        AND             civicrm_phone.phone_type_id =
                        AND             civicrm_phone.phone IS NOT NULL

... reveals the RHS of the test for phone_type_id is missing. I bet you don't have a phone-type called 'Mobile' (or perhaps you renamed 'Mobile' to (say) 'Cell'?). Add 'Mobile' and it should work.

Ken

PS: see the queries on lines 254, 311, and 436 of CRM/Mailing/BAO/Mailing.php for the code causing the problem.

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: SMS API Parameters
October 15, 2012, 04:52:17 am
I just had the same problem last night and debugged it exactly the same way. It may be something we need to look at in future releases - having an option in CiviSMS to select which location_type it uses for SMS messages.

You either have to rename your 'SMS' phone to Mobile, or change Mobile to whatever you 'SMS' phone is called in CRM/Mailing/BAO/Mailing.php.

Probably better to change your phone name to Mobile - but we should look at this in future releases.

Brian

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: SMS API Parameters
October 16, 2012, 12:53:37 am
Initially i thought code is doing the right thing and uses name column to identify phone-type-id and user could still change label to something else and work. But found it using label on further investigation.

Filed an issue here - http://issues.civicrm.org/jira/browse/CRM-11062.

The fix should allow user to change label for Mobile type and work with sms.

Don't think option to allow configuring phone type is really required if above works fine ?

thanks
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: SMS API Parameters
October 16, 2012, 05:12:35 am
That would work too. I use 'Cell' as my label, but unless you went into the DB and changed it manually, it stays as Mobile.

The only issue that could arise is if someone was to delete the Mobile Phone Type initially because they weren't using it, and later add a Cell phone type and put in Cell as the value (or something else). If there were to be a place to select which phone to use for SMS, I would suggest putting it in the Phone Type Options menu. Simply another checkbox saying 'Use for SMS'.

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: SMS API Parameters
October 16, 2012, 06:02:38 am
Quote
That would work too. I use 'Cell' as my label, but unless you went into the DB and changed it manually, it stays as Mobile.

Option label could be changed from UI. Doesn't require going to DB. Check the screen which lists all phone types.

Quote
initially because they weren't using it, and later add a Cell phone type and put in Cell

I would delete Cell and edit Mobile type label to Cell from UI.

Or if user has deleted Mobile type, could re-add Mobile-type and update label.
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: SMS API Parameters
October 17, 2012, 01:51:16 am
We could also make Mobile a reserved phone type since we probably want to prevent people from 'breaking' the system without knowing that they are doing so.
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Toeterniettoe

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: 4.6.alpha4
  • CMS version: Drupal 7.34
  • MySQL version: 5.5.41
  • PHP version: 5.3.25
Re: SMS API Parameters
October 18, 2012, 10:16:56 pm
Setting the phone_type back to "Mobile" solved the problem  :)

Thanks!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviSMS »
  • SMS API Parameters

This forum was archived on 2017-11-26.