www.webdeveloper.com
Results 1 to 4 of 4

Thread: Error with array inside query loop

Hybrid View

  1. #1
    Join Date
    Feb 2011
    Posts
    8

    Error with array inside query loop

    Code:
    <cfset var LOCAL = {}>
        	
            <cfquery name="qrysecnavtop" datasource="dev">
            
            SELECT pagename, subname, maincontent FROM ECpages
            WHERE navplacement = 2
            ORDER BY sortorder          
                
            </cfquery>
    
    <cfset secnavtopboxstring=ArrayNew(1)>
        	<cfset secnavbottomboxstring=ArrayNew(1)>
            <cfset LOCAL.count = 0>
    
    <cfloop query="qrysecnavtop">
            	<cfset LOCAL.count++>
                
                <cfset secnavtopboxstring[count]&= '<span>#qrysecnavtop.pagename#</span>#qrysecnavtop.subname#'>
               	<cfset secnavbottomboxstring&= '#qrysecnavtop.maincontent#'>     
            
            
            </cfloop>

    I keep getting this error....why?

    The element at position 1 cannot be found.

    The error occurred in C:\inetpub\wwwroot\ECDevSite\content.cfc: line 55

    53 : <cfset LOCAL.count++>
    54 :
    55 : <cfset secnavtopboxstring[count]&= '<span>#qrysecnavtop.pagename#</span>#qrysecnavtop.subname#'>
    56 : <cfset secnavbottomboxstring&= '#qrysecnavtop.maincontent#'>

  2. #2
    Join Date
    Feb 2011
    Posts
    8
    problem resolved

    it seems like:
    secnavtopboxstring[1] was undefined

  3. #3
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Sorry I didn't see this, earlier.

    I was thinking that because arrays are zero-based index and you started inserting at the second position ([1]) that might have had something to do with it.

    Glad you figured it out.

    ^_^

  4. #4
    Join Date
    Feb 2011
    Posts
    8
    Actually array's start at an index of 1 in Coldfusion I think

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles