Hey there. I can't seem to figure out an issue I'm having with cfhttp to make a query. I've got a very short tab delimited file (as a test) as follows Number Text 0 text for question one 1 Some ext for question 2, and more ... Code (markup): My cfhttp command is as follows <cfhttp method="Get" url="thefile.txt" textqualifier="" delimiter="#chr(9)#" name="questions" > Code (markup): I get the following error The column name " Column names must be valid variable names. They must start with a letter and can only include letters, numbers, and underscores. Code (markup): If I remove the name="" then I get an error later when trying to reference the query I've made. If I add in a columns specifier, then I get an error about having the wrong number of columns, no matter how many columns I specify. Any ideas would be appreciated. I'm using coldfusion 7. This is my frist real experience with CF here at work. Normally I'm using javascript. Thanks!
Error messages aren't always 100% accurate. But does your file follow the rules above? Usually you see that error when the file column headers contain bad characters. Examples of bad headers.... _Number Text Num(ber Text #umber T ext Also, it doesn't look like you need the "textqualifier" attribute. Since the values in your test file aren't quoted or anything.
I'm using the exact headers I listed above. The first line of the file is Number Text I thought I needed to specify textqualifier="" since the default is a " and it might then expect "1" "Text for the first question, and such" Anyone else? Does this make sense?
> url="thefile.txt" Plug in the full URL, not just the file name. ie http://localhost/pathto/thefile.txt
I don't know what to tell you then. The code works perfectly for me with the full url. That is assuming the sample data you posted is really tab delimited and is an accurate representation of your real file.. <cfhttp method="Get" url="http://localhost/test/testFile.txt" textqualifier="" delimiter="#chr(9)#" name="questions" > <cfdump var="#questions#">
Well, here is the exact error message, I've only edited out path and URL details. Maybe this will help someone help me? The column name " Column names must be valid variable names. They must start with a letter and can only include letters, numbers, and underscores. The error occurred in /directory/test.cfm: line 52 50 : url="http://www.myurl.com/reqquestions.txt" 51 : textqualifier="" 52 : delimiter="#chr(9)#" 53 : name="questions" 54 : > Code (markup): edit ... Also, for formatting the file, I only need a tab between each column, right? I shouldn't need a tab before the first column or after the last column, right?
Yep, you only need the tab between columns. Not before or after. I'm pretty sure your input file is messed up or is not really tab delimited. Because the code works perfectly with a correctly formatted file. <!--- generate a tab delimited file ...---> <cfsavecontent variable="fileText"><cfoutput> Number#chr(9)#Text 0#chr(9)#text for question one 1#chr(9)#Some ext for question 2, and more</cfoutput> </cfsavecontent> <!--- overwrite/save to disk ---> <cfset filePath = ExpandPath("/test/testFile.txt")> <cffile action="write" file="#filePath#" output="#fileText#"> <cfhttp method="get" url="http://localhost/test/testFile.txt" textqualifier="" delimiter="#chr(9)#" name="questions"> <cfdump var="#questions#"> Code (markup):
well, I've made more than one test file, and none of them are working. I'm using windows, so the end line characters might be different than those on a Unix server, which is what's running our ColdFusion. Would that be a problem for CF? I mean, if manually typing the text into notepad with tabs included, or saving a tab delineated file from Excel isn't good enough for CF then I'll push for some other technology. This problem has been was more trouble than it should be. Do you know of any other cold fusion forums I could post this question on? This was the only one I could find via google. More heads working on this might see something else.
I don't know what search phrase you were using, but the very 1st result on google for ColdFusion is adobe's own forums ... Though fyi, ColdFusion is one word (not two). forums.adobe.com/community/coldfusion
FYI Update So, I went to the adobe forums and started using a workaround where I just imported the file s text and then tried to convert it to a query. While dumping the text, I saw that I was actually getting my 404 page instead of the test file. I read the url again, and of course there was one character off. Having entered the correct url, my original code works just fine. Glad for resolution, but man do I feel like an idiot. Thanks again!
That makes two of us. I feel like an idiot for not suggesting you dump the chttp response in the first place ;-) Glad everything's copacetic now.