Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

String index out of range: -2

Explorer ,
Aug 03, 2010 Aug 03, 2010

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

1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 03, 2010 Aug 03, 2010

It is difficult to diagnose a problem without seeing the code in question.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2010 Aug 03, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 04, 2010 Aug 04, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 04, 2010 Aug 04, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 04, 2010 Aug 04, 2010

Thank you, I 'll give it a try

jim

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 04, 2010 Aug 04, 2010
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources