Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Output a variable within a variable

New Here ,
Dec 13, 2011 Dec 13, 2011

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.

787
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 13, 2011 Dec 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 13, 2011 Dec 13, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 13, 2011 Dec 13, 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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2011 Dec 13, 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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2011 Dec 13, 2011
LATEST

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources