Actually, if you have a variable already set as 'name', you can just evaluate() that entire string. I'd have to think that is easiest if it is already setup that way. Of course, rogue punds will always ruin ideas of doing it this way... like if someone decides to put "You are #1!!" in the string...
Personally, I'd use definitive markers (some may say #name# is just that) and replace those markers as Brian hinted at. I generally use something like <!--{{name}}--> Then replace "<!--{{name}}-->" with a variable value before displaying. If something happens, and the key is not replaced for whatever reason, it's an html comment and wont be seen in a browser or HTML email. .:.:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com http://cf4em.com -----Original Message----- From: Brian Cain [mailto:bcc9...@gmail.com] Sent: Friday, April 01, 2011 11:26 AM To: cf-talk Subject: Re: Including a variable within a database response Easiest way is to use the Replace function built in to CF. http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_ m-r_32.html <http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions _m-r_32.html>If you have multiple instances of the replacement value be sure to specify the "All" scope. You may also want to look at the ReplaceNoCase function. Brian Cain On Fri, Apr 1, 2011 at 10:22 AM, Scott Williams <myscottwilli...@yahoo.com>wrote: > > Hi all -- > > I have a script that draws some text from a database, and I would like to > embed > a person's name within the text. > > For example, the database field contains this text: > > Hi #name#. How's it going? > > I would like the #name# to be replaced with a previously defined variable > "name." > > Can ColdFusion do this? If so, how? > > Scott > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:343481 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm