Answers.Body: <p>You should test against the latest release (4.7.24) - it is likely fixed there</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-10T21:34:10.730Z
Answers.LastActivityDate: 2017-09-10T21:34:10.730Z
Answers.UserDisplayName: user4278
Answers.Body: <p>This seems to be related to an incorrect <code>website</code> join in the query. Is there any <code>website field</code> in your custom profile? </p>
  
  <p>If yes, you can try disabling/deleting it and check if you still find an issue.</p>
  
  <p>You can also raise a bug in <a href="https://issues.civicrm.org/" rel="nofollow noreferrer">JIRA</a> with some info of replicating the same.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-10T21:01:10.840Z
Answers.Text: thx, disabling the website field fixed the error!
Answers.UserDisplayName: Moe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-10T14:38:20.330Z
Answers.LastActivityDate: 2017-09-10T14:38:20.330Z
Answers.UserDisplayName: jitendra - fuzion
Body: <p>I'm running CiviCRM LTS (4.6.31) on Drupal 7.56 and a MySQL DB.</p>
  
  <p>i built a custom profile to simplify Contactcreation. Each time i add my custom tags to that form i get the DB Error: syntax error when saving a new contact. It'sstil created though.
  Contactcreation using der builtin form is working fine (even when setting tags)</p>
  
  <p>This is the error from the drupla log:</p>
  
  <pre><code>$Fatal error details = ARRAY ( [callback] =&gt; ARRAY ( [0] =&gt; crm_core_error [1] =&gt; handle ) [code] =&gt; -2 [message] =&gt; db error: syntax error [MODE] =&gt; 16 [debug_info] =&gt;
                                SELECT    contact_a.id                                           AS contact_id,
                                          contact_a.gender_id                                    AS `gender_id`,
                                          contact_a.first_name                                   AS `first_name`,
                                          contact_a.last_name                                    AS `last_name`,
                                          civicrm_note.id                                        AS note_id,
                                          civicrm_note.note                                      AS `note`,
                                          `1-location_type`.id                                   AS `1-location_type_id`,
                                          `1-location_type`.name                                 AS `1-location_type`,
                                          `1-email`.id                                           AS `1-email_id`,
                                          `1-email`.email                                        AS `1-email`,
                                          `1-phone`.id                                           AS `1-phone_id`,
                                          IF ( `1-phone`.is_primary = 1, `1-phone`.phone, NULL ) AS `1-phone`,
                                          `1-address`.id                                         AS `1-address_id`,
                                          `1-address`.state_province_id                          AS `1-state_province_id`,
                                          `1-address`.street_address                             AS `1-street_address`,
                                          `1-address`.postal_code                                AS `1-postal_code`,
                                          `1-address`.city                                       AS `1-city`,
                                          `website--url`.id                                      AS `website--url_id`,
                                          `website--url`.url                                     AS `website--url`,
                                          `website--url`.website_type_id                         AS `website--website_type_id`
                                FROM      civicrm_contact contact_a
                                left join civicrm_address `1-address`
                                ON        (
                                                    `1-address`.contact_id = contact_a.id
                                                    AND `1-address`.is_primary = 1 )
                                left join civicrm_email `1-email`
                                ON        contact_a.id = `1-email`.contact_id
                                          AND `1-email`.is_primary = 1
                                left join civicrm_phone `1-phone`
                                ON        contact_a.id = `1-phone`.contact_id
                                left join civicrm_location_type `1-location_type`
                                ON        ( (
                                                              `1-email`.location_type_id = `1-location_type`.id )
                                                    OR (
                                                              `1-phone`.location_type_id = `1-location_type`.id )
                                                    OR (
                                                              `1-address`.location_type_id = `1-location_type`.id ) )
                                left join civicrm_note
                                ON        (
                                                    civicrm_note.entity_table = 'civicrm_contact'
                                                    AND contact_a.id = civicrm_note.entity_id )
                                left join civicrm_website `website--url`
                                ON        (
                                                    `website--url`.contact_id = contact_a.id
                                                    AND `website--url`.website_type_id = )
                                WHERE     (
                                                    contact_a.id = '2968' )
                                          AND (
                                                    contact_a.is_deleted = 0 )
                                ORDER BY  `contact_a`.`sort_name` ASC,
                                          `contact_a`.`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 ') WHERE ( contact_a.id = '2968' ) AND (contact_a.is_deleted = 0) ORDER BY ' AT line 7] [TYPE] =&gt; db_error [user_info] =&gt;
                              SELECT    contact_a.id                                           AS contact_id,
                                        contact_a.gender_id                                    AS `gender_id`,
                                        contact_a.first_name                                   AS `first_name`,
                                        contact_a.last_name                                    AS `last_name`,
                                        civicrm_note.id                                        AS note_id,
                                        civicrm_note.note                                      AS `note`,
                                        `1-location_type`.id                                   AS `1-location_type_id`,
                                        `1-location_type`.name                                 AS `1-location_type`,
                                        `1-email`.id                                           AS `1-email_id`,
                                        `1-email`.email                                        AS `1-email`,
                                        `1-phone`.id                                           AS `1-phone_id`,
                                        IF ( `1-phone`.is_primary = 1, `1-phone`.phone, NULL ) AS `1-phone`,
                                        `1-address`.id                                         AS `1-address_id`,
                                        `1-address`.state_province_id                          AS `1-state_province_id`,
                                        `1-address`.street_address                             AS `1-street_address`,
                                        `1-address`.postal_code                                AS `1-postal_code`,
                                        `1-address`.city                                       AS `1-city`,
                                        `website--url`.id                                      AS `website--url_id`,
                                        `website--url`.url                                     AS `website--url`,
                                        `website--url`.website_type_id                         AS `website--website_type_id`
                              FROM      civicrm_contact contact_a
                              left join civicrm_address `1-address`
                              ON        (
                                                  `1-address`.contact_id = contact_a.id
                                                  AND `1-address`.is_primary = 1 )
                              left join civicrm_email `1-email`
                              ON        contact_a.id = `1-email`.contact_id
                                        AND `1-email`.is_primary = 1
                              left join civicrm_phone `1-phone`
                              ON        contact_a.id = `1-phone`.contact_id
                              left join civicrm_location_type `1-location_type`
                              ON        ( (
                                                            `1-email`.location_type_id = `1-location_type`.id )
                                                  OR (
                                                            `1-phone`.location_type_id = `1-location_type`.id )
                                                  OR (
                                                            `1-address`.location_type_id = `1-location_type`.id ) )
                              left join civicrm_note
                              ON        (
                                                  civicrm_note.entity_table = 'civicrm_contact'
                                                  AND contact_a.id = civicrm_note.entity_id )
                              left join civicrm_website `website--url`
                              ON        (
                                                  `website--url`.contact_id = contact_a.id
                                                  AND `website--url`.website_type_id = )
                              WHERE     (
                                                  contact_a.id = '2968' )
                                        AND (
                                                  contact_a.is_deleted = 0 )
                              ORDER BY  `contact_a`.`sort_name` ASC,
                                        `contact_a`.`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 ') WHERE ( contact_a.id = '2968' ) AND (contact_a.is_deleted = 0) ORDER BY ' AT line 7] [to_string] =&gt; [db_error: MESSAGE = "DB Error: syntax error" code = -2 MODE = callback callback = crm_core_error::handle prefix = "" info = "SELECT contact_a.id as contact_id, contact_a.gender_id as `gender_id`, contact_a.first_name as `first_name`, contact_a.last_name as `last_name`, civicrm_note.id as note_id, civicrm_note.note as `note`, `1 - location_type`.id as `1 - location_type_id`, `1 - location_type`.name as `1 - location_type`, `1 - email`.id as `1 - email_id`, `1 - email`.email as `1 - email`, `1 - phone`.id as `1 - phone_id`, IF (`1 - phone`.is_primary = 1, `1 - phone`.phone, NULL) as `1 - phone`, `1 - address`.id as `1 - address_id`, `1 - address`.state_province_id as `1 - state_province_id`, `1 - address`.street_address as `1 - street_address`, `1 - address`.postal_code as `1 - postal_code`, `1 - address`.city as `1 - city`, `website--url`.id as `website--url_id`, `website--url`.url as `website--url`, `website--url`.website_type_id as `website--website_type_id` FROM civicrm_contact contact_a LEFT JOIN civicrm_address `1-address` ON (`1-address`.contact_id = contact_a.id AND `1-address`.is_primary = 1) LEFT JOIN civicrm_email `1-emai] )
  </code></pre>
  
  <p>Any ideas how to fix this?</p>
  
  <p>Thx</p>
  
Tags: <profile><tags><lts>
Title: DB Error: syntax error when using custom profile to inut a new contact
ThreadText: # DB Error: syntax error when using custom profile to inut a new contact
  
  (Asked by: username_0 on 2017-09-10)
  
  I'm running CiviCRM LTS (4.6.31) on Drupal 7.56 and a MySQL DB.
  
  i built a custom profile to simplify Contactcreation. Each time i add my custom tags to that form i get the DB Error: syntax error when saving a new contact. It'sstil created though.
  Contactcreation using der builtin form is working fine (even when setting tags)
  
  This is the error from the drupla log:
  
  ```
  $Fatal error details = ARRAY ( [callback] => ARRAY ( [0] => crm_core_error [1] => handle ) [code] => -2 [message] => db error: syntax error [MODE] => 16 [debug_info] =>
                                SELECT    contact_a.id                                           AS contact_id,
                                          contact_a.gender_id                                    AS `gender_id`,
                                          contact_a.first_name                                   AS `first_name`,
                                          contact_a.last_name                                    AS `last_name`,
                                          civicrm_note.id                                        AS note_id,
                                          civicrm_note.note                                      AS `note`,
                                          `1-location_type`.id                                   AS `1-location_type_id`,
                                          `1-location_type`.name                                 AS `1-location_type`,
                                          `1-email`.id                                           AS `1-email_id`,
                                          `1-email`.email                                        AS `1-email`,
                                          `1-phone`.id                                           AS `1-phone_id`,
                                          IF ( `1-phone`.is_primary = 1, `1-phone`.phone, NULL ) AS `1-phone`,
                                          `1-address`.id                                         AS `1-address_id`,
                                          `1-address`.state_province_id                          AS `1-state_province_id`,
                                          `1-address`.street_address                             AS `1-street_address`,
                                          `1-address`.postal_code                                AS `1-postal_code`,
                                          `1-address`.city                                       AS `1-city`,
                                          `website--url`.id                                      AS `website--url_id`,
                                          `website--url`.url                                     AS `website--url`,
                                          `website--url`.website_type_id                         AS `website--website_type_id`
                                FROM      civicrm_contact contact_a
                                left join civicrm_address `1-address`
                                ON        (
                                                    `1-address`.contact_id = contact_a.id
                                                    AND `1-address`.is_primary = 1 )
                                left join civicrm_email `1-email`
                                ON        contact_a.id = `1-email`.contact_id
                                          AND `1-email`.is_primary = 1
                                left join civicrm_phone `1-phone`
                                ON        contact_a.id = `1-phone`.contact_id
                                left join civicrm_location_type `1-location_type`
                                ON        ( (
                                                              `1-email`.location_type_id = `1-location_type`.id )
                                                    OR (
                                                              `1-phone`.location_type_id = `1-location_type`.id )
                                                    OR (
                                                              `1-address`.location_type_id = `1-location_type`.id ) )
                                left join civicrm_note
                                ON        (
                                                    civicrm_note.entity_table = 'civicrm_contact'
                                                    AND contact_a.id = civicrm_note.entity_id )
                                left join civicrm_website `website--url`
                                ON        (
                                                    `website--url`.contact_id = contact_a.id
                                                    AND `website--url`.website_type_id = )
                                WHERE     (
                                                    contact_a.id = '2968' )
                                          AND (
                                                    contact_a.is_deleted = 0 )
                                ORDER BY  `contact_a`.`sort_name` ASC,
                                          `contact_a`.`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 ') WHERE ( contact_a.id = '2968' ) AND (contact_a.is_deleted = 0) ORDER BY ' AT line 7] [TYPE] => db_error [user_info] =>
                              SELECT    contact_a.id                                           AS contact_id,
                                        contact_a.gender_id                                    AS `gender_id`,
                                        contact_a.first_name                                   AS `first_name`,
                                        contact_a.last_name                                    AS `last_name`,
                                        civicrm_note.id                                        AS note_id,
                                        civicrm_note.note                                      AS `note`,
                                        `1-location_type`.id                                   AS `1-location_type_id`,
                                        `1-location_type`.name                                 AS `1-location_type`,
                                        `1-email`.id                                           AS `1-email_id`,
                                        `1-email`.email                                        AS `1-email`,
                                        `1-phone`.id                                           AS `1-phone_id`,
                                        IF ( `1-phone`.is_primary = 1, `1-phone`.phone, NULL ) AS `1-phone`,
                                        `1-address`.id                                         AS `1-address_id`,
                                        `1-address`.state_province_id                          AS `1-state_province_id`,
                                        `1-address`.street_address                             AS `1-street_address`,
                                        `1-address`.postal_code                                AS `1-postal_code`,
                                        `1-address`.city                                       AS `1-city`,
                                        `website--url`.id                                      AS `website--url_id`,
                                        `website--url`.url                                     AS `website--url`,
                                        `website--url`.website_type_id                         AS `website--website_type_id`
                              FROM      civicrm_contact contact_a
                              left join civicrm_address `1-address`
                              ON        (
                                                  `1-address`.contact_id = contact_a.id
                                                  AND `1-address`.is_primary = 1 )
                              left join civicrm_email `1-email`
                              ON        contact_a.id = `1-email`.contact_id
                                        AND `1-email`.is_primary = 1
                              left join civicrm_phone `1-phone`
                              ON        contact_a.id = `1-phone`.contact_id
                              left join civicrm_location_type `1-location_type`
                              ON        ( (
                                                            `1-email`.location_type_id = `1-location_type`.id )
                                                  OR (
                                                            `1-phone`.location_type_id = `1-location_type`.id )
                                                  OR (
                                                            `1-address`.location_type_id = `1-location_type`.id ) )
                              left join civicrm_note
                              ON        (
                                                  civicrm_note.entity_table = 'civicrm_contact'
                                                  AND contact_a.id = civicrm_note.entity_id )
                              left join civicrm_website `website--url`
                              ON        (
                                                  `website--url`.contact_id = contact_a.id
                                                  AND `website--url`.website_type_id = )
                              WHERE     (
                                                  contact_a.id = '2968' )
                                        AND (
                                                  contact_a.is_deleted = 0 )
                              ORDER BY  `contact_a`.`sort_name` ASC,
                                        `contact_a`.`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 ') WHERE ( contact_a.id = '2968' ) AND (contact_a.is_deleted = 0) ORDER BY ' AT line 7] [to_string] => [db_error: MESSAGE = "DB Error: syntax error" code = -2 MODE = callback callback = crm_core_error::handle prefix = "" info = "SELECT contact_a.id as contact_id, contact_a.gender_id as `gender_id`, contact_a.first_name as `first_name`, contact_a.last_name as `last_name`, civicrm_note.id as note_id, civicrm_note.note as `note`, `1 - location_type`.id as `1 - location_type_id`, `1 - location_type`.name as `1 - location_type`, `1 - email`.id as `1 - email_id`, `1 - email`.email as `1 - email`, `1 - phone`.id as `1 - phone_id`, IF (`1 - phone`.is_primary = 1, `1 - phone`.phone, NULL) as `1 - phone`, `1 - address`.id as `1 - address_id`, `1 - address`.state_province_id as `1 - state_province_id`, `1 - address`.street_address as `1 - street_address`, `1 - address`.postal_code as `1 - postal_code`, `1 - address`.city as `1 - city`, `website--url`.id as `website--url_id`, `website--url`.url as `website--url`, `website--url`.website_type_id as `website--website_type_id` FROM civicrm_contact contact_a LEFT JOIN civicrm_address `1-address` ON (`1-address`.contact_id = contact_a.id AND `1-address`.is_primary = 1) LEFT JOIN civicrm_email `1-emai] )
  
  ```
  
  Any ideas how to fix this?
  
  Thx
  
  **Tags:** profile, tags, lts
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-09-10. Score: 0 | Accepted answer
  
  You should test against the latest release (4.7.24) - it is likely fixed there
  
  
  ---
  
  ### Answer by username_2 on 2017-09-10. Score: 1
  
  This seems to be related to an incorrect `website` join in the query. Is there any `website field` in your custom profile?
  
  If yes, you can try disabling/deleting it and check if you still find an issue.
  
  You can also raise a bug in [JIRA](https://issues.civicrm.org/) with some info of replicating the same.
  
  > **Comments:**
  > **username_0**: thx, disabling the website field fixed the error!  
  
  ---
  
  