<cfquery name="TheSearch" datasource="TheDatabase">
SELECT *
FROM    TheTable
WHERE  TheTextField LIKE '%#SearchString#%'
</cfquery>


And yes, you will want to 'encode' the variable inside a <cfqueryparam> tag,
otherwise you'll wake up one morning with "hacked by the chinese" on your
home page.

Adam.



> -----Original Message-----
> From: Eric Homa [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 05, 2003 3:50 PM
> To: CF-Talk
> Subject: Need Help With Query
> 
> 
> Hi,
> 
> I have a query that I need to use to search a text field in a 
> table.  The text strings that are in the table in this field 
> sometimes include a pound sign (#).  Whenever I the query is 
> run using a variable that includes a pound sign it returns no 
> records. Here is an abbreviated example of my code.
> 
> There are two templates.  The first is a form:
> 
> <cfform action="Search.cfm" method="Post">
> <cfinput type="text" name="SearchString">
> <input type="submit">
> </cfform>
> 
> The second page:
> 
> <cfquery name="TheSearch" datasource="TheDatabase">
> SELECT *
> FROM    TheTable
> WHERE  TheTextField = '#SearchString#'
> </cfquery>
> 
> Do I need to encode the variable somehow?
> 
> Thanks,
> 
> Eric Homa
> 
> 
> 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to