Skip to main content
Participant
February 11, 2012
Answered

Can figure out stupid, simple cfif, cfoutput error

  • February 11, 2012
  • 2 replies
  • 3102 views

For some reason when I put in this simple code I get an error that an opening cfoutput tag is missing.  What is going on????

<cfparam name="ss" default="3">

<cfif (ss is 3)>

<cfoutput query="sssplayer">

<cfelse>

<cfoutput>

</cfif>

  

--content here--

</cfoutput>

This is the error:

The end tag </cfoutput> encountered on line 12 at column 3 requires a matching start tag.

The CFML compiler was processing:

  • The body of a cfoutput tag beginning on line 7, column 2.

PLEASE HELP!  I've been coding ColdFusion for 16 years!!

This topic has been closed for replies.
Correct answer Adam Cameron.

Like I said, they need to be nested properly.  You can have an OPENING tag provided you've also got a CLOSING tag.

<cfif condition>

     <cfoutoput query="foo">

          <!--- stuff --->

     </cfoutput>

<cfelse>

     <cfoutoput>

          <!--- stuff --->

     </cfoutput>

</cfif>

--

Adam

2 replies

BKBK
Community Expert
Community Expert
February 12, 2012

daktws wrote:

For some reason when I put in this simple code I get an error that an opening cfoutput tag is missing.  What is going on????

<cfparam name="ss" default="3">

<cfif (ss is 3)>

<cfoutput query="sssplayer">

<cfelse>

<cfoutput>

</cfif>

  

--content here--

</cfoutput>

This is the error:

The end tag </cfoutput> encountered on line 12 at column 3 requires a matching start tag.

The CFML compiler was processing:

  • The body of a cfoutput tag beginning on line 7, column 2.

PLEASE HELP!  I've been coding ColdFusion for 16 years!!

Just an explanation why you got the error. The first thing ColdFusion does to a CFM page is read and compile it. Compilation is concerned with checking the basic syntax. For example, that the language is correct, that tags like cfloop and cfoutput that require end-tags do in fact get end-tags, and so on. The moment one such "grammatical" rule is broken, compilation stops. ColdFusion then shows you the compilation error.

It is very much like a human Editor proof-reading a manuscript and stumbling on the sentence "I go to the fair yesterday.". Whereas the Editor may likely read on, a compiler stops compiling when it encounters an error. So, take your passage,

<cfif (ss is 3)>

<cfoutput query="sssplayer">

<cfelse>

<cfoutput>

</cfif>

--content here--

</cfoutput>

The logic of the if-then-else block is deferred to a later process, interpretation. The compiler proceeds further, and encounters the end tag </cfoutput>. The alarm bell goes. The compiler hadn't encountered a matching <cfoutput> earlier.

Inspiring
February 11, 2012

CFML tags need to be nested correctly; you can't have one opening tag in the TRUE block and one in the FALSE block of a <cfif> statement.

--

Adam

daktwsAuthor
Participant
February 11, 2012

So I can't have a cfoutput in the true and in the false?