Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

whats wrong with this code

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
Eduski
Asked:
Eduski
  • 5
  • 3
1 Solution
 
EduskiAuthor Commented:
and please dont yell at me about the font tags... i know i know
0
 
EduskiAuthor Commented:
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
 
tim_csCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
EduskiAuthor Commented:
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
 
tim_csCommented:
Can you post all of the information it's giving you for the error?  
0
 
EduskiAuthor Commented:
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
 
tim_csCommented:
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
 
EduskiAuthor Commented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now