Skip to main content
Inspiring
August 3, 2010
Question

String index out of range: -2

  • August 3, 2010
  • 2 replies
  • 1824 views

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

    This topic has been closed for replies.

    2 replies

    Inspiring
    August 4, 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

    rockhikerAuthor
    Inspiring
    August 4, 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

    Inspiring
    August 4, 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

    Inspiring
    August 3, 2010

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