?
Solved

coldfusion syntax error

Posted on 2013-02-01
4
Medium Priority
?
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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 …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

741 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