Solved

Expand variable embedded inside an sql table

Posted on 2006-11-08
3
310 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
3 Comments
 
LVL 2

Expert Comment

by:pegarm
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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 showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now