Terry,
I have had the same problem -- it usually happens when you are using a query
variable from a loop inside a nested loop. Set the first loop query
variable to a temp variable to use in your nested loop. e.g:
<CFLOOP QUERY="qry_missions">
<CFQUERY NAME="qry_missioncomm" DATASOURCE="#request.mainDSN#">
SELECT *
FROM tbl_node
WHERE node_id IN
(
SELECT node_id
FROM tbl_mission_comm
WHERE mission_id = #qry_missions.mission_id#
)
</CFQUERY>
<CFOUTPUT>#qry_missions.mission_id#,#qry_missioncomm.recordcount#</CFOUTPUT>
-before<BR>
<CFSET test = qry_missions.mission_id>
<!--- Add this --->
<cfset tmpMission_ID = qry_missions.mission_id>
<cfset tmpNode_ID = qry_missioncomm.node_id>
<CFLOOP QUERY="qry_missioncomm">
<CFOUTPUT>#test# should equal
#qry_missions.mission_id#</CFOUTPUT>-test<BR>
<CFQUERY NAME="qry_missionq" DATASOURCE="#request.mainDSN#">
SELECT *
FROM tbl_question
WHERE q_node = #tmpnode_id#
AND q_mission = #tmpmission_id#
AND q_deleted = 0
</CFQUERY>
<CFOUTPUT>#qry_missioncomm.node_id#-node
#qry_missions.mission_id#-mission</CFOUTPUT><BR>
</CFLOOP>
</CFLOOP>
----- Original Message -----
From: "Terry Bader" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, May 03, 2001 10:25 AM
Subject: Unusual Results, help
> Ok, i'm having some problems with the below code.... here's the problem...
> in the loop <CFLOOP QUERY="qry_missioncomm"> it is always seeing
> qry_missions.mission_id being 1....
>
> if you notice the test code i put in just before it, i see that
> qry_missions.mission_id is and check to make sure the previous query has
> records... then i set a test variable to qry_missions.mission_id
> as such:
>
>
<CFOUTPUT>#qry_missions.mission_id#,#qry_missioncomm.recordcount#</CFOUTPUT>
> -before<BR>
> <CFSET test = qry_missions.mission_id>
>
> so in the 2nd iteration of this loop, i get:
> 2,9-before
>
> with test being set to 2
>
> now comes the loop:
> <CFLOOP QUERY="qry_missioncomm">
>
> followed by:
> <CFOUTPUT>#test# should equal
#qry_missions.mission_id#</CFOUTPUT>-test<BR>
>
> and wtf??? i get:
> 2 should equal 1-test
>
> ?????????? why isnt the qry_missions.mission_id equal to 2 inside the
> second loop??? there are no other declarations here and after the loop,
> qry_missions.mission_id is equal to 2....
>
>
> CODE HERE:
> --------------------------------------------------------------------------
--
> -----------------------------------------------------------
>
> <CFQUERY NAME="qry_missions" DATASOURCE="#request.mainDSN#">
> SELECT *
> FROM tbl_mission
> WHERE mission_id <> 0
> </CFQUERY>
>
> <CFLOOP QUERY="qry_missions">
>
> <CFQUERY NAME="qry_missioncomm" DATASOURCE="#request.mainDSN#">
> SELECT *
> FROM tbl_node
> WHERE node_id IN
> (
> SELECT node_id
> FROM tbl_mission_comm
> WHERE mission_id = #qry_missions.mission_id#
> )
> </CFQUERY>
>
>
>
<CFOUTPUT>#qry_missions.mission_id#,#qry_missioncomm.recordcount#</CFOUTPUT>
> -before<BR>
> <CFSET test = qry_missions.mission_id>
>
> <CFLOOP QUERY="qry_missioncomm">
>
> <CFOUTPUT>#test# should equal
> #qry_missions.mission_id#</CFOUTPUT>-test<BR>
>
> <CFQUERY NAME="qry_missionq" DATASOURCE="#request.mainDSN#">
> SELECT *
> FROM tbl_question
> WHERE q_node = #qry_missioncomm.node_id#
> AND q_mission = #qry_missions.mission_id#
> AND q_deleted = 0
> </CFQUERY>
>
> <CFOUTPUT>#qry_missioncomm.node_id#-node
> #qry_missions.mission_id#-mission</CFOUTPUT><BR>
>
> </CFLOOP>
> </CFLOOP>
>
>
> Terry Bader
> IT/Web Specialist
> Macromedia Certified Coldfusion Developer
> EDO Corp - Combat Systems
> (757) 424-1004 ext 361 - Work
> [EMAIL PROTECTED]
>
>
> (757)581-5981 - Mobile
> [EMAIL PROTECTED]
> icq: 5202487 aim: lv2bounce
> http://www.cs.odu.edu/~bader
>
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists