Skip to main content
January 3, 2012
Answered

Invalid tag nesting configuration error - help please!

  • January 3, 2012
  • 2 replies
  • 4187 views

I'm a total newbie to CF and inherited this application at my organization.  I'm receiving this error: 

Invalid Tag Nesting Configuration on a CF9 server.

The app does use the cfoutput with the <option value>.  This is where it is choking:

The error occurred in E:\~mld\Nurse\inc_Patients.cfm: line 125

123 :        <cfelse>

124 :             <option value= ""></option>

125 :                               <cfoutput query="SortedPatients">

126 :                 <cfif Len(pid)><option value= "#registry_id#{#pid#}">#p_firstname# #p_lastname#</option></cfif>

127 :             </cfoutput>

Here is the entire <cfform> code if this helps.

<cfform action="index.cfm" method="POST"><!--- Select a patient --->

    Select a patient:

    <select name="P" id="">

        <cfif Len(P)>

            <option value= "#P#">#SelectedPatient_FirstName# #SelectedPatient_LastName#</option>

            <option value= ""></option>

                              <cfoutput query="SortedPatients">

                <cfif P neq pid and Len(pid)><option value= "#registry_id#{#pid#">#p_firstname# #p_lastname#</option></cfif>

            </cfoutput>

        <cfelse>

            <option value= ""></option>

                              <cfoutput query="SortedPatients">

                <cfif Len(pid)><option value= "#registry_id#{#pid#">#p_firstname# #p_lastname#</option></cfif>

            </cfoutput>

        </cfif>

    </select>

    <input type="submit" value="Get patient">

    <input type="hidden" name="z" value="0147134"><!--- 0147134: Patients (inc_Patients.cfm) --->

    <input type="hidden" name="lx" value="1"><!--- Output/update patient forms --->

</cfform>

Any help is greatly appreciated.  I am trying to go into production with this, however I need to get this functionality working.  Thanks in advance!

This topic has been closed for replies.
Correct answer Owainnorth

Yes, it is which is confusing. I totally inherited this app and don't understand how it could have worked on their servers.  Here is the code below.  Do you have any thoughts on remediation or a better way to rewrite?  I'm totally new at this.

<cfoutput>

<div style="padding-top: .5em;">

<cfform action="index.cfm" method="POST"><!--- Select a patient --->

    Select a patient:

    <select name="P" id="">

        <cfif Len(P)>

            <option value= "#P#">#SelectedPatient_FirstName# #SelectedPatient_LastName#</option>

            <option value= ""></option>

                              <cfoutput query="SortedPatients">

                <cfif P neq pid and Len(pid)><option value= "#registry_id#{#pid#">#p_firstname# #p_lastname#</option></cfif>

            </cfoutput>

        <cfelse>

            <option value= ""></option>

                              <cfoutput query="SortedPatients">

                <cfif Len(pid)><option value= "#registry_id#{#pid#">#p_firstname# #p_lastname#</option></cfif>

            </cfoutput>

        </cfif>

    </select>

    <input type="submit" value="Get patient">

    <input type="hidden" name="z" value="0147134"><!--- 0147134: Patients (inc_Patients.cfm) --->

    <input type="hidden" name="lx" value="1"><!--- Output/update patient forms --->

</cfform>

</div>

</cfoutput>


Yes, change the <cfoutput query=""> blocks (and closing blocks) to <cfloop query=""> blocks.

2 replies

Participating Frequently
January 3, 2012

Usually the only time you have a <cfoutput> tag within another <cfoutput> tag is when you are using the GROUP feature. This feature allows you to group the results of a sql query without using GROUP BY in your sql query, it can come in handy at times. Here is an example:

Query to get data from database:

<cfquery name="qryStudents" datasource="dsn1">

  SELECT Class, Student

  FROM Enrollment

</cfquery>

We want to output the data from this query to a website, but we want to group the students by the class they are in, since one or more students can be in the same class. We want the name of the class listed first, followed by the names of the students, this is simple to do using nested <cfoutput> and GROUP attribute. Where the class will be the GROUP value.

Here is how we would output the data using coldfusion. The first cfoutput uses the GROUP attribute, the nested cfoutput is normal.

<cfoutput query="qryStudents" group="class">

   Class: #Class#

   <br>

  

<cfoutput>

      #Student#

      <br>

   </cfoutput>

</cfoutput>

This coldfusion code will give you output like the following, depending on what is in your database.

Class One

        Student 1

        Student 3

Class Two

       Student 2

One important note, if you have a <cfoutput> tag with query and group attributes set, it cannot be nested within another <cfoutput> tag, this will cause an error. I have used this method in websites that offer Electronic Components and semiconductors for sale.

Hope this helps.

Michael G. Workman

mworkman@usbid.com

http://www.usbid.com

http://ic.locate-ic.com

January 3, 2012

I so appreciate you taking the time to explain the appropriate use of cfoutput Michael.  Thanks much!

January 3, 2012

if anyone can help and needs more info, please don't hesitate to message me.  Thanks!  I'm really confused about this error.  Even if you can only send me documentation or a link to some sort of helpful post in the documentation, I totally appreciate it! 

Owainnorth
Inspiring
January 3, 2012

Is the entire cfform block inside a cfoutput block? You can't have a cfoutput inside another, which it sounds like is the issue.

January 3, 2012

Yes, it is which is confusing. I totally inherited this app and don't understand how it could have worked on their servers.  Here is the code below.  Do you have any thoughts on remediation or a better way to rewrite?  I'm totally new at this.

<cfoutput>

<div style="padding-top: .5em;">

<cfform action="index.cfm" method="POST"><!--- Select a patient --->

    Select a patient:

    <select name="P" id="">

        <cfif Len(P)>

            <option value= "#P#">#SelectedPatient_FirstName# #SelectedPatient_LastName#</option>

            <option value= ""></option>

                              <cfoutput query="SortedPatients">

                <cfif P neq pid and Len(pid)><option value= "#registry_id#{#pid#">#p_firstname# #p_lastname#</option></cfif>

            </cfoutput>

        <cfelse>

            <option value= ""></option>

                              <cfoutput query="SortedPatients">

                <cfif Len(pid)><option value= "#registry_id#{#pid#">#p_firstname# #p_lastname#</option></cfif>

            </cfoutput>

        </cfif>

    </select>

    <input type="submit" value="Get patient">

    <input type="hidden" name="z" value="0147134"><!--- 0147134: Patients (inc_Patients.cfm) --->

    <input type="hidden" name="lx" value="1"><!--- Output/update patient forms --->

</cfform>

</div>

</cfoutput>