Len doesn't evaluate true or false. It returns a number relating to the number of characters in the string.
<!----------------//------ andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --------------//---------> -----Original Message----- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Thursday, June 01, 2006 2:54 PM To: CF-Talk Subject: RE: Problems with LEN Bruce, Don't use quotes in your Len call : LEN( Form.FirstName ) NOT LEN("Form.FirstName") If you use quotes, that will always evaluate to true since the string "Form.firstname" has a length. ........................ Ben Nadel www.bennadel.com -----Original Message----- From: Bruce Sorge [mailto:[EMAIL PROTECTED] Sent: Thursday, June 01, 2006 3:43 PM To: CF-Talk Subject: Problems with LEN OK, I have this query: <cfquery datasource="#Session.DSN#" name="qSearchResults"> SELECT ContactID, FIrstName, LastName, DateModified FROM Contact WHERE 0=0 AND <cfif LEN("Form.FirstName") GT 0> FirstName <cfif Form.searchCriteria IS "exactPhrase"> = '#Form.FirstName#' <cfelseif Form.searchCriteria IS "allWords"> LIKE '%#Form.FirstName#%' </cfif> </cfif> <cfif LEN("Form.LastName") GT 0> AND LastName <cfif Form.searchCriteria IS "exactPhrase"> = '#Form.LastName#' <cfelseif Form.searchCriteria IS "allWords"> LIKE '%#Form.LastName#%' </cfif> </cfif> </cfquery> I can dump the LEN of firstname and lastname. So if I do not enter anything in the lastname field and enter something in the firstname field, the len for firstname is X and the LEN for lastname is 0, so by allrights it should only do the AND FirstName = "#Form.FirstName# if I select exactPhrase. The only way it works if I enter something in one field but not the other is if I select allWords, because it is using the LIKE operator. So why is it that if I use ExactPhrase it executes the following query: SELECT ContactID, FirstName, LastName, DateModified FROM Contact WHERE 0=0 AND FirstName = 'Bruce' AND LastName = ' ' LastName should not even be a part of the query if I do not enter anything into it. Thanks, Bruce Sorge ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:241958 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

