Eduski
asked on
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]#</fo nt></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></t d>
<td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat( price)#</f ont></td>
<td valign=top align=right><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat( totalunitp rice)#</fo nt></td>
</tr>
</cfoutput>
</cfloop>
</cfif>
</cfif>
<cfset subtotal = 0>
<cfif isdefined("session.cart")>
<cfif IsStruct(session.cart)>
<cfloop collection="#session.cart#
<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[
<td valign="top">
<font size="2" face="Arial, Helvetica, sans-serif">#description#<
<td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#rentalperiod#
<td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat(
<td valign=top align=right><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat(
</tr>
</cfoutput>
</cfloop>
</cfif>
</cfif>
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.o Src;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_pre loadImages .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&&p arent.fram es.length) {
d=parent.frames[n.substrin g(p+1)].do cument; 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.len gth;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.arg uments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+= 3)
if ((x=MM_findObj(a[i]))!=nul l){documen t.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></stron g></font>< /div></td>
<br>
<td><div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><strong>PRODUCT</ strong></f ont></div> </td>
<td width="40" align="right"> <div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font size="2">RENTAL
PERIOD</font></strong></fo nt></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></fon t></div></ td>
<td width="99" align="right"><div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font size="2">TOTAL
PRICE</font></strong></fon t></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]#</fo nt></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></t d>
<td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat( price)#</f ont></td>
<td valign=top align=right><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat( totalunitp rice)#</fo nt></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>Subtot al:
#dollarformat(subtotal)#<b r>
Tax: #dollarformat(salesTax)#<b r>
Total: #dollarformat(total)#</str ong></font ></div></t d>
</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#</cfoutpu t></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></f ont></div> </td>
</tr>
</table>
</body>
</html>
</cfmail>
<!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=
}
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_pre
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&&p
d=parent.frames[n.substrin
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;
for(i=0;!x&&d.layers&&i<d.
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arg
if ((x=MM_findObj(a[i]))!=nul
}
//-->
</script>
<cfscript>
subtotal = 0;
</cfscript>
<cfmail from="mail@abcwny.com" to="ad004m@mail.rochester.
<!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></
</tr>
<tr>
<td bgcolor="##000000"> <div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font color="##FFFFFF" size="2">Submission
Receipt:</font></strong></
</tr>
<tr>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">Order Contents:</font></strong><
</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></stron
<br>
<td><div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><strong>PRODUCT</
<td width="40" align="right"> <div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font size="2">RENTAL
PERIOD</font></strong></fo
<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></fon
<td width="99" align="right"><div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font size="2">TOTAL
PRICE</font></strong></fon
</tr>
<td>
<cfloop collection="#session.cart#
<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[
<td valign="top">
<font size="2" face="Arial, Helvetica, sans-serif">#description#<
<td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#rentalperiod#
<td align=right valign=top><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat(
<td valign=top align=right><font size="2" face="Arial, Helvetica, sans-serif">#dollarformat(
</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>Subtot
#dollarformat(subtotal)#<b
Tax: #dollarformat(salesTax)#<b
Total: #dollarformat(total)#</str
</tr>
<tr>
<td bgcolor="##000000"><strong
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#</cfoutpu
</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></f
</tr>
</table>
</body>
</html>
</cfmail>
Can you post all of the information it's giving you for the error?
ASKER
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.NullPointerExcep tion
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.NullPointerExcep
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.
ASKER
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.
ASKER