Skip to main content
AvalancheWHO
Participant
December 13, 2011
Question

Output a variable within a variable

  • December 13, 2011
  • 4 replies
  • 830 views

This might sound a bit strange but I have a system running that serves ads from a variety of sources. The problem is that I need to append a UUID inside the string called from the database.

<cfoutput>

#ad_details#

</cfoutput>

The variable called from the query outputs as:

<SCRIPT language='JavaScript1.1' SRC="http://adserverlink#CreateUUID()#">

</SCRIPT>

The problem is that it outputs the CreateUUID as seen above and not as the expected output of a UUID.

Hope that makes sense.

Thanks in advance.

This topic has been closed for replies.

4 replies

BKBK
Community Expert
Community Expert
December 14, 2011

AvalancheWHO wrote:

This might sound a bit strange but I have a system running that serves ads from a variety of sources. The problem is that I need to append a UUID inside the string called from the database.

...

The problem is that it outputs the CreateUUID as seen above and not as the expected output of a UUID.

Go back to the place where you intended to insert the UUID to the database. Yoy will find that you inserted the string #CreateUUID()# instead of the string <cfoutput>#CreateUUID()#</cfoutput>

BKBK
Community Expert
Community Expert
December 14, 2011

AvalancheWHO wrote:

The variable called from the query outputs as:

<SCRIPT language='JavaScript1.1' SRC="http://adserverlink#CreateUUID()#">

</SCRIPT>

The problem is that it outputs the CreateUUID as seen above and not as the expected output of a UUID.

<cfoutput><SCRIPT type="text/javascript" language='JavaScript1.1' SRC="http://adserverlink#CreateUUID()#">

</SCRIPT></cfoutput>

Inspiring
December 13, 2011

It might be easier if the UUID was a url variable instead of the actual url.

Inspiring
December 14, 2011

ColdFusion's implementation of UUID is slightly different, use this function to generate a SQL-Server like one...

<cffunction name="MicrosoftUUID" access="public" output="false">

     <cfreturn insert("-", CreateUUID(), 23) />

</cffunction>

Inspiring
December 13, 2011

You can't simply output a string and expect it to execute!

You will need to write your string to a file, then INCLUDE it, rather than just output it.

Do a search on these forums (perhaps best to do it via Google than the inbuilt forum search) for "code in variable" or "dynamic code" or "evaluate" and read some of the threads discussing this: this crops up every six months or so, so there should be good discussions on it.

--

Adam