Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Apostrophe problem in cf8 mysql

Guest
May 09, 2009 May 09, 2009

I am getting an error using cfqueryparam.  I feel like this is the same way I used to use it in CF7.  I have some data.  It has a single quote apostrophe buried in it.  And, it fails.  So, this below is a simplified version.  I am using CF 8, and mysql 5.x

Error Executing Database Query.
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 'fulltext, sectionid, catid) values ('test', 'This is great\'s info', 'another te' at line 1

The error occurred in /web/htdocs/abbott_stuff/joomla/moveDataIntoJoomla.cfm: line 75

73 : <!--- Insert a record into the joomla database --->
74 : <cfquery name="second" datasource="joomla">
75 : Insert into jos_content (title, alias, introtext, fulltext, sectionid, catid) values ('test', <cfqueryparam value="This is great's info" cfsqltype="cf_sql_varchar">, 'another test', 'test text', #first.joomlaSection#, #first.joomlaCategory#)
76 :
77 : <!--- Insert into jos_content (title,alias,introtext, fulltext, state, sectionid, mask, catid, created_by, created_by_alias, version) values (<cfqueryparam value="#first.title#" cfsqltype="cf_sql_varchar">, <cfqueryparam value="#safeTitle#" cfsqltype="cf_sql_varchar">, <cfqueryparam value="#first.description#" cfsqltype="cf_sql_varchar">, <cfqueryparam value="#first.content#">, 1, #first.joomlaSection#, 0, #first.joomlaCategory#, 0, <cfqueryparam value="#first.author#" cfsqltype="cf_sql_varchar">,1) --->

SQLSTATE       42000
SQL        Insert into jos_content (title, alias, introtext, fulltext, sectionid, catid) values ('test', (param 1) , 'another test', 'test text', 10, 151)
VENDORERRORCODE       1064
DATASOURCE       joomla

TOPICS
Getting started
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 09, 2009 May 09, 2009

That's weird, you don't need to escape the apostrophe because it's inside a double quotation mark. I assume that you've already removed the apostrophe and test it. Seems like a bug in CF 8.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 09, 2009 May 09, 2009

The error I was getting was a total red hering.  Your suggestion helped.  I tracked it down and discovered that the real problem was the field name alias is a  reserved word in mysql.  So, I had to enclose the field names in backticks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 09, 2009 May 09, 2009
LATEST

Great, CF doesn't have bugs then

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources