Skip to main content
May 10, 2009
Question

Apostrophe problem in cf8 mysql

  • May 10, 2009
  • 1 reply
  • 1116 views

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

This topic has been closed for replies.

1 reply

Michael Borbor
Inspiring
May 10, 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.

May 10, 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.

Michael Borbor
Inspiring
May 10, 2009

Great, CF doesn't have bugs then