like this
#PreserveSingleQuotes(list
Main Topics
Browse All TopicsI have a search function that crashes if <cfset Criteria = "((abstract Like '%#listItem#%' OR headline like '%#listItem#%')"> has a comma in the listitem . For example: Sams Club works fine but Sam's Club crashes. Just wondering how to go about fixing this bug.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If you want to create your criteria for your CFQUERY in a variable first you will need to double up the single quotes in your "listitem" and then use preserve single quotes in your cfquery.
eg.
<cfset variables.Criteria = "(abstract Like '%"&replace(listItem,"'","
<cfquery name="searchresults" datasource="mydsn">
SELECT *
FROM tblArticles
<cfif StructKeyExists(variables,
WHERE #PreserveSingleQuotes(vari
</cfif>
</cfquery>
This is a bit long winded when
<cfquery name="searchresults" datasource="mydsn">
SELECT *
FROM tblArticles
WHERE abstract Like <cfqueryparam cfsqltype="cf_sql_varchar"
OR headline like <cfqueryparam cfsqltype="cf_sql_varchar"
</cfquery>
would be a much safer query and much more efficient on the cf code and in terms of the SQL itself.
However, I would suggest you look at using verity to do full text indexing of abstract and headline or utilise the full text functionality of your database, rather than doing LIKE SQL statements.
Business Accounts
Answer for Membership
by: javasharpPosted on 2006-01-19 at 05:21:24ID: 15738456
How about using PreserveSingleQuotes function? .com/coldf usion/6.1/ htmldocs/ f uncta53.ht m
http://livedocs.macromedia