Solved

coldfusion syntax error

Posted on 2013-02-01
4
246 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

15 Experts available now in Live!

Get 1:1 Help Now