Skip to main content
Known Participant
September 3, 2008
Question

Storing cf tags in database

  • September 3, 2008
  • 5 replies
  • 772 views
Hi,
I am storing in database some text that has coldfusion tags in it. For example:

quote:

This is page #url.pageNum#


When I retrieve this text from the db and display it using cfoutput, the #url.pageNum# does not get processed. Instead, it is shown as a text. What do I do in order to get the coldfusion variable be evaluated?

Thanks,
Min
    This topic has been closed for replies.

    5 replies

    Inspiring
    September 3, 2008
    Try doing a search of these forums.

    This question comes up about once a month, so you should be able to dig up
    one of the threads that answered this the last time it was asked.

    It's generally better to use Google to do the search than use the "native"
    search.

    --
    Adam
    MCL97Author
    Known Participant
    September 4, 2008
    Do you have any suggestion for search keywords to use? I tried some variations of 'storing coldfusion variables in database table' but did not find what I am looking for. Thanks.

    Min

    quote:

    Originally posted by: Newsgroup User
    Try doing a search of these forums.

    This question comes up about once a month, so you should be able to dig up
    one of the threads that answered this the last time it was asked.

    It's generally better to use Google to do the search than use the "native"
    search.

    --
    Adam



    Inspiring
    September 4, 2008
    quote:

    Originally posted by: MCL97
    Do you have any suggestion for search keywords to use? I tried some variations of 'storing coldfusion variables in database table' but did not find what I am looking for. Thanks.


    So did I with an equal lack of success. But you've already been given the two most common answers, write a file or use evaluate().

    September 3, 2008
    can you post some code samples?
    MCL97Author
    Known Participant
    September 3, 2008
    <!--- Storing the text --->
    <cfquery>
    insert into faq(questionNum,question,answer)
    values(1,'How much is shipping?','Shipping is #dollarFormat(request.shippingCost)#')
    </cfquery>

    <!--- Retrieving and displaying it --->
    <cfquery name="getFAQ">
    select question, answer
    from faq
    where questionNum=1
    </cfquery>

    <cfoutput query="getFAQ">
    Question: #question# <br>
    Answer: #answer#
    </cfoutput>

    <!---The displayed output --->
    Question: How much is shipping?
    Answer: Shipping is #dollarFormat(request.shippingCost)#

    <!--- What I want --->
    Question: How much is shipping?
    Answer: Shipping is $5.00
    MCL97Author
    Known Participant
    September 3, 2008
    Dan, this is for our FAQ list and we are currently storing it in text files. I am attempting to move them to the database so that we can manage them a little easier.

    speedpedal, I tried substituting #url.pageNum# with #evaluate(url.pageNum)# but it doesn't work. The problem is that when the string gets retrieved from the db and displayed using <cfoutput>, coldfusion variables in the form of #varName# are not being evaluated and are instead being treated as string. I suppose I could pull out all the #varName# from the text, have them evaluated, and then insert the values back into the text.

    Thanks,
    Min
    September 3, 2008
    or use the Evaluate function

    #Evaluate(url.pagenum)#

    be careful of using this function... it is CPU/process intensive. So proceed with caution.
    Inspiring
    September 3, 2008
    Write it to a file and cfinclude the file.