Skip to main content
Inspiring
September 19, 2008
Question

cfif and like

  • September 19, 2008
  • 4 replies
  • 5074 views
I have a data collection that uses verity, I want to eliminate any results that contain the word footer in them. This is my code< i am overlooking something and I feel it is due to lack of sleep. Any thoughts? thanks
    This topic has been closed for replies.

    4 replies

    Inspiring
    September 20, 2008
    Here is the syntax...

    <cfif key contains 'footer'>

    <cfelseif len(foundResults.title) EQ 0>
    <a href="interior.cfm?Cid=#key#">- Result - </a>
    <cfelse>
    <a href="#foundResults.URL#" target="_blank"> #foundResults.title#</a>
    </cfif>



    You don't need to check if key is not "" because it will not contain footer if it's empty.

    You also don't need the # signs inside the CFIF


    Inspiring
    September 19, 2008
    On Fri, 19 Sep 2008 18:49:11 +0000 (UTC), brianism wrote:

    > Try changing this
    > <cfif #key# is not "">
    > and #key# is LIKE '%footer%'
    >
    > to this
    >
    > <cfif #key# NEQ "" AND #key# is LIKE '%footer%'>

    Can you please talk us through why you made this post / suggestion?

    --
    Adam
    Inspiring
    September 22, 2008
    quote:

    Originally posted by: Newsgroup User
    On Fri, 19 Sep 2008 18:49:11 +0000 (UTC), brianism wrote:

    > Try changing this
    > <cfif #key# is not "">
    > and #key# is LIKE '%footer%'
    >
    > to this
    >
    > <cfif #key# NEQ "" AND #key# is LIKE '%footer%'>

    Can you please talk us through why you made this post / suggestion?

    --
    Adam



    That would be because I could not remember if it should have been LIKE or CONTAIN. This coding stuff turns my mind into mush sometimes.
    Inspiring
    September 19, 2008
    "like" is an sql keyword. The equivalent cf function is contains. Usage is described in the cfml reference manual and livedocs.
    Inspiring
    September 19, 2008
    Try changing this
    <cfif #key# is not "">
    and #key# is LIKE '%footer%'

    to this

    <cfif #key# NEQ "" AND #key# LIKE '%footer%'>
    jazz823Author
    Inspiring
    September 19, 2008
    Iget the following error

    Invalid CFML construct found on line 34 at column 30.
    ColdFusion was looking at the following text:

    LIKE

    The CFML compiler was processing:

    * a cfif tag beginning on line 34, column 2.