array append error "Object of type class java.lang.String cannot be used as an array"
Copy link to clipboard
Copied
I have an array that I would like to continue adding items to. Setting the array and displaying the contents works fine but when I try to append I get the error message "Object of type class java.lang.String cannot be used as an array" Should this be a structure? or do I have my looping in the wrong place? The goal is to combine 200 arrays into the content variable so I can write a .csv file to the server.
Here's the basics:
<cfset content= ArrayNew(1)>
run queries
<cfset content = "#q14.name#" &","& "#big
(this part above displays correctly in a cfdump with the items from the query which looks like this
Category, Written communication, 10)
<cfloop index="k" from="1" to="5">
<cfset temp = arrayappend(content, "#q14.name# ,#big
</cfloop>
I've also tried something as simple as <cfset ArrayAppend(content, "hello test")> which still gives the above error message.
Copy link to clipboard
Copied
Here's the basics:
<cfset content= ArrayNew(1)>
This line create a one diminsional array named 'content'
<cfset content = "#q14.name#" &","& "#big [1]#" & "," & "#big [2]#" & chr(10)>
This line overrides the array varaibale named 'content' with a string value converting it into a string variable.
<cfset temp = arrayappend(content, "#q14.name# ,#big [1]#, #big [2]#" & chr(10))>
This line tries to append an array element to the now converted string variable named 'content'
Message was edited by: Ian Skinner String Variable NOT String Array
Copy link to clipboard
Copied
Why not keep it as simple as
<cfloop index="k" from="1" to="5">
<cfset content
</cfloop>

