Copy link to clipboard
Copied
hello,
when i submit a form I get the message String index out of range: -2 on line 126 which is the formfields of the cfinsert. Does anyone have any ideas or a suggestion on how to debug the issue.
Thank you
jim
Copy link to clipboard
Copied
It is difficult to diagnose a problem without seeing the code in question.
Copy link to clipboard
Copied
Remove the <cfinsert>, and use a <cfquery>.
Also the suggestion to post the code you're having problems with is always a helpful one.
--
Adam
Copy link to clipboard
Copied
How do you use a query to insert form data into a database? I thought queries return data?
Jim Oyler
Information Services
County Road Administration Board
360.664.3299 X243
Copy link to clipboard
Copied
The CFQUERY tag can be used for a variety of SQL commands, not just SELECT queries.
Here is an exmple that uses CFQUERY to insert data:
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0e02b-7ff3.html#WSc3ff6d0ea77859461172e0811cbec0e02b-7ffc
I reccommend that you also use CFQUERYPARAM within your CFQUERY blocks.
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7c36.html
Copy link to clipboard
Copied
Thank you, I 'll give it a try
jim
Copy link to clipboard
Copied
Yeah <cfinsert> and <cfupdate> are just "wizard" type tags for quick&dirty sort of stuff. They don't offer much control over what goes on, and also generate fairly shonky SQL too. The accepted "industry knowledge" is to avoid them for anything other than curio value, and getting answers right on tests.
--
Adam