Skip to main content
Known Participant
December 8, 2008
Question

SQL Query Error Help !!

  • December 8, 2008
  • 3 replies
  • 428 views
Here is the Query:
<cfquery name="get_facilities" dbtype="query">
SELECT
shopid, name, address, city, zip, phone, keyword
FROM get_shops
WHERE(
<cfloop index="i" list="#form.keywords#" delimiters=" ">
UPPER(keywords_#request.language#) LIKE UPPER('%#i#%') AND
</cfloop>
UPPER(keywords_#request.language#) LIKE '%%')
ORDER BYzip
</cfquery>

Here is the error:
"The Pattern of the LIKE conditional is malformed"

Here is what was entered in the keyword field in the form, the person was searching for "star auto[obile".
automobile was misspelled with a [.

How do I fix this? Can I fix it in the query?
    This topic has been closed for replies.

    3 replies

    Inspiring
    December 9, 2008
    UPPER(keywords_#request.language#) LIKE '%#UCASE(i)#%' AND

    and, as Ian mentioned already: use cfqueryparam or be sorry!

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Inspiring
    December 9, 2008
    What does the sql look like in your error message?
    Inspiring
    December 8, 2008
    Joe Science wrote:

    >
    > How do I fix this? Can I fix it in the query?
    >

    Most likely this can be fixed with the recommended used of the
    <cfqueryparam...> tag for all user variables input into a SQL statement.
    It will protect you from SQL injection as well.

    UPPER(keyword_#request.languate#_ LIKE UPPPER(<cfqueryparam
    value="%#i#%" cfsqltype="cf_sql_varchar">) AND

    Known Participant
    December 9, 2008
    Got the same error. doesnt seem to work.