Testing a variable for inequality

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Testing a variable for inequality

    What i'm doing is: if a searched term is not found in the database, it will
    redirect the user back to the search page.
    However, here is my problem, each time i compare the form input value against
    the retrieved database value, nothing happens and it just continues on through
    the rest of the code. What have i done wrong? it seems strange to me that a
    blank field could still be equal to a field with a value.

    The code:
    <CFQUERY NAME="get_data" DATASOURCE="datasource">
    SELECT * FROM CustomerDetails WHERE #Form.searchType# = '#Form.searchTerm#'
    </CFQUERY>

    <cfoutput query="get_data">
    <cfif Form.searchTerm IS NOT CustomerID>
    <cflocation url="url.com">
    <cfelseif Form.searchTerm IS NOT CompanyName>
    <cflocation url="url.com">
    </cfif>
    </cfoutput>
    ...

    I've also tried using
    <cfif CustomerID IS "">
    But that did the exact same thing...

    xSeanx Guest

  2. Similar Questions and Discussions

    1. #39251 [NEW]: variable variable class array property is read only
      From: taskfreak at gmail dot com Operating system: mac os PHP version: 5.1.6 PHP Bug Type: Class/Object related Bug...
    2. inequality question
      I'm having trouble trying to run a query that returns rows that don't match. The code below returns all the matching rows but what I need is all the...
    3. Checking inequality
      I have the following code in one of my trigger functions --------------------------------------------------------------- IF...
    4. #22237 [Com]: PHP crashes when class references property using variable variable
      ID: 22237 Comment by: rep at devdomain dot com Reported By: peter at globalvision dot com dot au Status: Closed...
    5. Testing for the existance of an Application() variable
      How about this: theLetter="G" If len(Application(theLetter)) > 0 then HTH, Bob Barrows
  3. #2

    Default Re: Testing a variable for inequality

    You could just check how many records were returned from the query and make
    your decision to redirect from there.
    See attached code.
    HTH
    Zoe

    <CFQUERY NAME="get_data" DATASOURCE="datasource">
    SELECT *
    FROM CustomerDetails
    WHERE #Form.searchType# = '#Form.searchTerm#'
    </CFQUERY>

    <CFIF get_data.RecordCount EQ 0>
    <cflocation url="url.com">
    <CFELSE>
    otherwise match was found ...
    </CFIF>

    zoeski80 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139