Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 31)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

[SOLVED] SQL Syntax Error: 1604

  • don5420
  • don5420
  • OFFLINE
  • Posts: 55
  • Thanks: 3
  • Karma: 0
11 years 2 months ago - 11 years 2 months ago #234607 by don5420
[SOLVED] SQL Syntax Error: 1604 was created by don5420
I created a custom field of type query. It works just fine. However, if you go into the administration section, click the community builder menu, proceed to user management and then click the "New" button, it returns this error:

Error: 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 '[user_id]' at line 1 SQL=SELECT `payment_status` FROM `abca_cbsubs_payments` WHERE `item_name` LIKE '%2014%' and `for_user_id` = [user_id]

The SQL syntax is correct and works just fine for returning the results that I am looking for in their profile. Therefore, I know that it isn't the syntax. Except that [user_id] is a CB variable, so maybe it doesn't know how to handle it when starting from scratch.

Some more information: It is a field type of Query. The SQL query is exactly as listed above.
There is no pre-filled value.
Required: NO
Show on Profile: Yes on 1 line
Display field title in profile: Yes
Searchable: No
User Read Only?: Yes
Show at Registration?: No
Published: Yes
Last edit: 11 years 2 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
11 years 2 months ago - 11 years 2 months ago #234611 by krileon
Replied by krileon on topic SQL Syntax Error: 1604
You need to use quotes for substitution values. They always return a string and adding a string straight to a query is invalid SQL. Your query should be as follows.

Code:
SELECT `payment_status` FROM `#__cbsubs_payments` WHERE `item_name` LIKE '%2014%' AND `for_user_id` = '[user_id]'


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 11 years 2 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • don5420
  • don5420
  • OFFLINE
  • Posts: 55
  • Thanks: 3
  • Karma: 0
11 years 2 months ago #234615 by don5420
Replied by don5420 on topic SQL Syntax Error: 1604
Doesn't work. If I do that the error becomes:

Error: 1054 Unknown column '[user_id]' in 'where clause' SQL=SELECT `payment_status` FROM `abca_cbsubs_payments` WHERE `item_name` LIKE '%2014%' and `for_user_id` = `[user_id]`

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
11 years 2 months ago - 11 years 2 months ago #234617 by krileon
Replied by krileon on topic SQL Syntax Error: 1604
Please read my reply previous carefully. You need to use single quotes ( ' ). Your error has apostrophes ( ` ). You must use single or double quotes for values. Apostrophes are only for table names and column names.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 11 years 2 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • don5420
  • don5420
  • OFFLINE
  • Posts: 55
  • Thanks: 3
  • Karma: 0
11 years 2 months ago #234619 by don5420
Replied by don5420 on topic SQL Syntax Error: 1604
You are correct. My mistake. It is working now. Strange that it worked to produce the information I needed in their profile without the quotes.

Thanks and mark this as solved!
The following user(s) said Thank You: krileon

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum