Solved

whats wrong with this code

Posted on 2004-08-12
8
187 Views
Last Modified: 2013-12-24
i keep gettin the error that there are imporoper nested cfoutput tags, please help            

<cfset subtotal = 0>
            <cfif isdefined("session.cart")>
            <cfif IsStruct(session.cart)>
       
        <cfloop collection="#session.cart#" item="i">
          <cfquery datasource="products" name="loopproduct">select * from allproducts
          where productid = #session.cart[i][1]# and periodid = #session.cart[i][2]#
          </cfquery>
          <cfoutput query="loopproduct">
            <cfset totalunitprice = session.cart[i][3] * price>
            <cfset subtotal = subtotal + totalunitprice>
            <tr>
              <td>
                <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">#session.cart[i][3]#</font></div></td>
              <td valign="top">
                <font size="2" face="Arial, Helvetica, sans-serif">#description#</font></td>
              <td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#rentalperiod#</font></td>
              <td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat(price)#</font></td>
              <td valign=top align=right><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat(totalunitprice)#</font></td>
            </tr>
                  </cfoutput>
        </cfloop>
            </cfif>
            </cfif>
0
Comment
Question by:Eduski
  • 5
  • 3
8 Comments
 
LVL 3

Author Comment

by:Eduski
ID: 11787024
and please dont yell at me about the font tags... i know i know
0
 
LVL 3

Author Comment

by:Eduski
ID: 11787048
and it says:

Invalid tag nesting configuration.  
A query driven CFOUTPUT tag is nested inside a CFOUTPUT tag that also has a QUERY= attribute. This is not allowed. Nesting these tags implies that you want to use grouped processing. However, only the top-level tag can specify the query that drives the processing

with the error pointing to the <cfoutput query="loopproduct"> line
0
 
LVL 15

Accepted Solution

by:
tim_cs earned 250 total points
ID: 11787424
Try and change <cfoutput query="loopproduct"> to a cfloop

<cfset subtotal = 0>
          <cfif isdefined("session.cart")>
          <cfif IsStruct(session.cart)>
       
        <cfloop collection="#session.cart#" item="i">
          <cfquery datasource="products" name="loopproduct">select * from allproducts
          where productid = #session.cart[i][1]# and periodid = #session.cart[i][2]#
          </cfquery>
          <cfloop query="loopproduct">
            <cfset totalunitprice = session.cart[i][3] * price>
            <cfset subtotal = subtotal + totalunitprice>
            <tr>
              <td>
                <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">#session.cart[i][3]#</font></div></td>
              <td valign="top">
                <font size="2" face="Arial, Helvetica, sans-serif">#description#</font></td>
              <td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#rentalperiod#</font></td>
              <td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat(price)#</font></td>
              <td valign=top align=right><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat(totalunitprice)#</font></td>
            </tr>
               </cfloop>
        </cfloop>
          </cfif>
          </cfif>
0
 
LVL 3

Author Comment

by:Eduski
ID: 11787965
ok that gets me around the first problem, but for an extra 250 pts, can anyone tell me why the heck it is telling me a variable is undefined?  i will post the code for teh whole page, presumably it is the "subtotal" variable, but I can't figure it out for hte life of me.  Please ignore all very poorly formatted font tags.  THanks,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ABC: Hardware, Rental, Special Events</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="abcstyle.css">
</head>

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

<cfscript>
subtotal = 0;
</cfscript>

<cfmail from="mail@abcwny.com" to="ad004m@mail.rochester.edu" subject="ABCWNY.com Order Submission" server="mail.abcwny.com" port="25" type="html">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<title>ABCWNY.com Order Submission</title>
<body>
<table width="520" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="16" bgcolor="##FFFFFF"> <p align="left"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Here
        is an order submission from the website:</strong></font></p></td>
  </tr>
  <tr>
    <td bgcolor="##000000"> <div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font color="##FFFFFF" size="2">Submission
        Receipt:</font></strong></font></div></td>
  </tr>
  <tr>
    <td><strong><font size="2" face="Arial, Helvetica, sans-serif">Order Contents:</font></strong></td>
  </tr>
  <tr>
    <td valign="top"><table border=0 width="520" cellspacing="0">
        <tr>
          <td width="20"><div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font size="2">QTY</font></strong></font></div></td>
          <br>
          <td><div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><strong>PRODUCT</strong></font></div></td>
          <td width="40" align="right"> <div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font size="2">RENTAL
              PERIOD</font></strong></font></div>
            <div align="center"></div></td>
          <td width="40" align="right"><div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font size="2">UNIT
              PRICE</font></strong></font></div></td>
          <td width="99" align="right"><div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font size="2">TOTAL
              PRICE</font></strong></font></div></td>
        </tr>
        <td>
        <cfloop collection="#session.cart#" item="i">
          <cfquery datasource="products" name="loopproduct">select * from allproducts
          where productid = #session.cart[i][1]# and periodid = #session.cart[i][2]#
          </cfquery>
          <cfloop query="loopproduct">
            <cfset totalunitprice = session.cart[i][3] * price>
            <cfset subtotal = subtotal + totalunitprice>
            <tr>
              <td>
                <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">#session.cart[i][3]#</font></div></td>
              <td valign="top">
                <font size="2" face="Arial, Helvetica, sans-serif">#description#</font></td>
              <td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#rentalperiod#</font></td>
              <td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat(price)#</font></td>
              <td valign=top align=right><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat(totalunitprice)#</font></td>
            </tr>
               </cfloop>
        <cfscript>
         salesTax = subtotal * 0.0825;
         total = subtotal + salesTax;
       </cfscript></cfloop>
       </table></tr>
    <tr>
    <td><cfoutput><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Subtotal:
        #dollarformat(subtotal)#<br>
        Tax: #dollarformat(salesTax)#<br>
        Total: #dollarformat(total)#</strong></font></div></td>
  </tr>
  <tr>
    <td bgcolor="##000000"><strong><font color="##FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Personal
      Info:</font></strong></td>
  </tr>
  <tr>
    <td height="141"> <p><font face="Arial, Helvetica, sans-serif"><strong><font size="2">
        #form.pname#<br>
        #form.address#<br>
        <cfif form.address2 neq "">
          #form.address2#<br>
        </cfif>
        #form.citystatezip#<br>
        <br>
        Email: #form.email#<br>
        Phone: #form.phone#<br>
        Date of rental: #form.rentalmth# #form.rentalday#, #form.rentalyear#<br>
        Time of Rental: #form.rentaltime#</cfoutput></font></strong></font></p></td>
  </tr>
  <tr>
    <td height="16" bgcolor="##000000">
      <div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font color="##FFFFFF" size="2">
        End Submission Receipt</font></strong></font></div></td>
  </tr>
</table>
</body>
  </html>
  </cfmail>
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:tim_cs
ID: 11788250
Can you post all of the information it's giving you for the error?  
0
 
LVL 3

Author Comment

by:Eduski
ID: 11792270
Not sure if this is going to be much help, but here is the error

Error Occurred While Processing Request  
The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.
Null Pointers are another name for undefined values.  
 
 
Please try the following:
Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.

 
Browser   Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)
Remote Address   128.205.92.212
Referrer   http://www.mysite.com/confirmorder.cfm
Date/Time   13-Aug-04 05:38 AM
 
Stack Trace (click to expand)  



java.lang.NullPointerException

 

 
0
 
LVL 15

Expert Comment

by:tim_cs
ID: 11792977
I think the problem is in the <cfloop> for the session.  I don't think you can loop through session variables like that then have session.cart[i][1].  But,  I haven't worked with sessions alot so I would post another question or a pointer question to this one so other experts will look.  Sorry I couldn't be of more help on this one.
0
 
LVL 3

Author Comment

by:Eduski
ID: 11792998
ok thanks for your time on the first issue... you can loop through, I do it in a different page, so thats not the issue, thanks for the help.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

746 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

8 Experts available now in Live!

Get 1:1 Help Now