Solved

coldfusion syntax error

Posted on 2013-02-01
4
245 Views
Last Modified: 2013-02-04
Hi experts,

I have a syntax error in these code but I can't see where.

The error shown is :
Invalid CFML construct found on line 341 at column 23.
ColdFusion was looking at the following text:
;

		<!--- get form's data & store into pages (cfc's) --->
		<cfloop list="#variables.languages#" index="variables.lang">
			<!--- get & store default language's data --->
			<cfif variables.lang EQ application.languageByDefault>
				<!--- title --->
				<cfset variables["cfc_" & variables.lang].setTitle(evaluate('form.title_#application.languages["#variables.lang#"]#'))>
				<cfset variables.defaultTitle = evaluate('form.title_#application.languages["#variables.lang#"]#')>
				<!--- description --->
				<cfset variables["cfc_" & variables.lang].setDescription(evaluate('form.description_#application.languages["#variables.lang#"]#'))>
				<cfset variables.defaultDescription = evaluate('form.title_#application.languages["#variables.lang#"]#')>
				<!--- keywords --->
				<cfset variables["cfc_" & variables.lang].setKeywords(evaluate('form.keywords_#application.languages["#variables.lang#"]#'))>
				<cfset variables.defaultKeywords = evaluate('form.title_#application.languages["#variables.lang#"]#')>
				<!--- page's body --->
				<cfset variables["cfc_" & variables.lang].setBody(evaluate('form.body_#application.languages["#variables.lang#"]#'))>
				<cfset variables.defaultBody = evaluate('form.title_#application.languages["#variables.lang#"]#')>
				<!--- save data to the database --->
				<cfset entitySave(evaluate('variables.cfc_#variables.lang#'))>
				<cfset ormFlush()>
				<cfbreak>
			</cfif>
		</cfloop>

Open in new window



the line 341 is the line below
<!--- title --->
:
		<cfloop list="#variables.languages#" index="variables.lang">
			<!--- get & store other language's data --->
			<cfif variables.lang NEQ application.languageByDefault>
				<!--- title --->
				<cfset variables.valueToTest = evaluate('form.title_#application.languages["#variables.lang#"]#')>
				<cfif variables.valueToTest NEQ "">
					<cfset variables["cfc_" & variables.lang].setTitle(evaluate('form.title_#application.languages["#variables.lang#"]#'))>
				<cfelse> <!--- this language's value is empty : store default language's value --->
					<cfset variables["cfc_" & variables.lang].setTitle(variables.defaultTitle)>
				</cfif>
				<!--- description --->
				<cfset variables.valueToTest = evaluate('form.description_#application.languages["#variables.lang#"]#')>
				<cfif variables.valueToTest NEQ "">
					<cfset variables["cfc_" & variables.lang].setDescription(evaluate('form.description_#application.languages["#variables.lang#"]#'))>
				<cfelse> <!--- this language's value is empty : store default language's value --->
					<cfset variables["cfc_" & variables.lang].setDescription(variables.defaultDescription)>
				</cfif>
				<!--- keywords --->
				<cfset variables.valueToTest = evaluate('form.keywords_#application.languages["#variables.lang#"]#')>
				<cfif variables.valueToTest NEQ "">
					<cfset variables["cfc_" & variables.lang].setKeywords(evaluate('form.keywords_#application.languages["#variables.lang#"]#'))>
				<cfelse> <!--- this language's value is empty : store default language's value --->
					<cfset variables["cfc_" & variables.lang].setKeywords(variables.defaultKeywords)>
				</cfif>
				<!--- page's body --->
				<cfset variables.valueToTest = evaluate('form.body_#application.languages["#variables.lang#"]#')>
				<cfif variables.valueToTest NEQ "">
					<cfset variables["cfc_" & variables.lang].setBody(evaluate('form.body_#application.languages["#variables.lang#"]#'))>
				<cfelse> <!--- this language's value is empty : store default language's value --->
					<cfset variables["cfc_" & variables.lang].setBody(variables.defaultBody)>
				</cfif>
				<!--- save data to the database --->
				<cfset entitySave(evaluate('variables.cfc_#variables.lang#'))>
				<cfset ormFlush()>
			</cfif>
		</cfloop>

Open in new window


Do you have an idea ?
0
Comment
Question by:adam1h
  • 2
4 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 38844384
Don't trust error messages 100%.  Sometimes the error line # is way past the actual problem. It's just where the compiler gave up.

I don't see any semi-colons ";" in that code.  Are there any semi-colon's in the sections leading up to that line?

Complete shot in the dark, but sometimes I get that error when converting cfscript to cfml and forget to change the closing mark from ";" to ">", causing that error  ie

                  <cfset b = 123;              <=== invalid
                  <cfset b = 123>             <=== valid
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 38844389
It's curious that you seem very comfortable using the structure format but then also throw in unnecessary "evaluate()" functions with extra quotes.

I suggest rewriting for clearify and simplicy

These lines ...
<cfset variables["cfc_" & variables.lang].setTitle(evaluate('form.title_#application.languages["#variables.lang#"]#'))>
<cfset variables.defaultTitle = evaluate('form.title_#application.languages["#variables.lang#"]#')>

Open in new window


Can be rewritten as follows..
<cfset variables.defaultTitle = form.["title_" & application.languages[variables.lang]]>
<cfset variables["cfc_" & variables.lang].setTitle(variables.defaultTitle)>

Open in new window



Note that the second version uses the "defaultTitle" variable that you created so you don't have to derrive the same value twice.
0
 

Author Comment

by:adam1h
ID: 38844413
Hi both,

No I haven't any ; in my code.

Us I will try to rewrite & simplify

We'll see
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38844442
Yeah, I'd agree you should refactor. I'd rollback the "bad" changes and start with a last know "good" copy. Go from there.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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