QUOTE(xheartonfire43x @ 6 May, 2009 - 06:28 AM)

I am adding a simple search feature to my company's call tracking system where they could either search for the client's company, name, email, or reference id. Also they can select either completed or uncompleted tasks. The query is no using the part that says whether or not to get completed tasks or not. I am guessing that it is because of all of my LIKE clauses.
CODE
<cfquery name="getTickets" datasource="#mydatasource#" username="#myusername#" password="#mypassword#">
SELECT * FROM worklist
<cfif isDefined('completed')>
WHERE completed = '#completed#'
</cfif>
AND fullname LIKE <cfqueryparam value="%#form.search#%">
OR email LIKE <cfqueryparam value="%#form.search#%">
OR clientID = <cfqueryparam value="#getClient.clientid#">
OR uniqueid LIKE <cfqueryparam value="%#form.search#%">
ORDER BY datecompleted,lastupdated
</cfquery>
Try this instead:
CODE
<cfquery name="getTickets" datasource="#mydatasource#" username="#myusername#" password="#mypassword#">
SELECT * FROM worklist
WHERE fullname LIKE <cfqueryparam value="%#form.search#%">
<cfif isDefined('completed')>
AND completed = '#completed#'
</cfif>
OR email LIKE <cfqueryparam value="%#form.search#%">
OR clientID = <cfqueryparam value="#getClient.clientid#">
OR uniqueid LIKE <cfqueryparam value="%#form.search#%">
ORDER BY datecompleted,lastupdated
</cfquery>
This post has been edited by armyCoder: 6 May, 2009 - 08:05 AM