Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Expand variable embedded inside an sql table

Posted on 2006-11-08
3
Medium Priority
?
318 Views
Last Modified: 2013-12-24
How can I expand a variable which is embedded within a table column, itself expanded by a cfquery output?

A query, FilesInfo.description, is enclosed with cfoutput tags (see below). This is a column inside my sql table, data type varchar.

I want to edit the contents of FilesInfo.description and insert a variable in the middle of the text. When FilesInfo.description is expanded, the new variable is also expanded.

I guess you can see this as a variable within a variable, and it seems to me I read one cannot do this. But I'm hoping there is another way.

Here's the contents of "filesInfo.description".

"Story of a group of filmmakers traveled to Skull Island. <cfoutput>#variable#</cfoutput> They intended to investigate legends of a giant gorilla named Kong."

The problem is when expanded, #FilesInfo.description# displays my embedded variable name like this:

"This is the story of a group of explorers and documentary filmmakers traveled to Skull Island.  #variable# There they intend to investigate legends of a giant gorilla named Kong."

The variable is not expanded. Is there a workaround or a different method to do this without having to change my database design?


<cfquery name="FilesInfo" datasource="Library">
  select description
  from areas
  where area_id = #area_id#
</cfquery

<cfoutput>#FilesInfo.description#</cfoutput>

  - Georgia


0
Comment
Question by:RollinNow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:pegarm
ID: 17904925
Try this:

<cfquery name="FilesInfo" datasource="Library">
  select description
  from areas
  where area_id = #area_id#
</cfquery

<cfoutput>#evaluate(FilesInfo.description)#</cfoutput>
0
 
LVL 4

Accepted Solution

by:
CodeParadise earned 2000 total points
ID: 17905110
The evaluate function wasn't working in my testing. You can also approach your problem this way.

<cfquery name="FilesInfo" datasource="Library">
  select description
  from areas
  where area_id = #area_id#
</cfquery

<cfset var = "12345678">
<cfset newText = Replace(FilesInfo.description, "##variable##", var)>
<cfoutput>#newText#</cfoutput>
0
 

Author Comment

by:RollinNow
ID: 17909968
CodeParadise,

The evaluate function didn't work for me either, but your solution does. I should have thought of it. Makes sense.  However, to get it to work for me, I had to do this:

<cfset newText = Replace(FilesInfo.description, "babygunk", "#var#", "ALL")>

babygunk is just some text I know I'll never use so it's unique and does not need to be a set variable.  It replaces babygunk with my defined variable, var.

 Thanks for your help, and thanks, pegarm, for the attempt.


   - Georgia
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question