If form.service_population isn't defined, you have an empty WHERE
clause. That's probably the root of the issue. I suggest having
something in your WHERE clause that's always true but has no bearing
on the returned results, like "WHERE 0=0" then add the rest of your
dynamic clause.


On Mon, 10 Jan 2005 13:10:06 -0500, Daniel Kessler <[EMAIL PROTECTED]> wrote:
> I'm doing my first Search utility:
> http://hhp.umd.edu/studentservices/internships.cfm
> 
> I'm trying to build a WHERE clause in CF where it check to see if a
> form field is part of a search and if it is, then it builds into the
> WHERE string.  Unfortunatley when I do, I get the error, "SQL command
> doesn't end properly" after clicking Search.
> 
> Here's some of the code:
> 
> <cfif structKeyExists(Form,"service_population") OR
> structKeyExists(Form,"agency") OR structKeyExists(Form,"city") OR
> structKeyExists(Form,"state") OR
> structKeyExists(Form,"salary_status")>
> 
>     <cfoutput>
>   <--- setup a search --->
>     <cfset find_text = "WHERE ">
>     <cfif structKeyExists(Form,"service_population")>
>        <!--- <cfset find_text ="WHERE service_population='children'">--->
>        <cfset find_text
> ="#find_text#service_population='#Form.service_population#'">
>     </cfif>
> 
>     <cfquery name="getSearchItem" datasource="dpch">
>        SELECT service_population,agency,city,state,salary_status
>        FROM internships
>        #find_text#
>        ORDER BY agency ASC
>     </cfquery>
> 
>     </cfoutput>
> <cfelse>
>   <--- setup some presets --->
>     <cfset service_population = ''>
>     <cfset agency = ''>
>     <cfset city = ''>
>     <cfset state = ''>
>     <cfset salary_status = ''>
> 
> </cfif>
> 
> Also, if someone can just point me to a tutorial on this, then that'd be fine.
> Really, any help would be appreciated.
> 
> --
> Daniel Kessler
> 
> Department of Public and Community Health
> University of Maryland
> Suite 2387 Valley Drive
> College Park, MD  20742-2611
> 301-405-2545 Phone
> www.phi.umd.edu
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189824
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

Reply via email to