Professional Web Applications Themes

Trouble with INSERT statement - Coldfusion - Getting Started

I'm trying to create my very first INSERT statement, but I keep getting an error and I can't figure out why. The error: Syntax error in INSERT INTO statement All fields are text, so everything is quoted. I tried to trim all form variables ('#TRIM(form.filename)#') and that didn't work either. Any ideas on what I'm doing wrong? Thank you in advance for your help. <cfquery name="addProduct" datasource="southshore"> INSERT INTO PRODUCTS_TEST (FILENAME, NUMBER, TITLE, CATEGORY, DESIGNER, BUILDER, COLLECTION, DESCRIPTION, DIMENSIONS, ACTIVE) VALUES ('#form.filename#', '#form.number#', '#form.title#', '#form.category#', '#form.designer#', '#form.builder#', '#form.collection#', '#form.description#', '#form.dimensions#', '#form.active#') </cfquery>...

  1. #1

    Default Trouble with INSERT statement

    I'm trying to create my very first INSERT statement, but I keep getting an
    error and I can't figure out why.

    The error: Syntax error in INSERT INTO statement

    All fields are text, so everything is quoted. I tried to trim all form
    variables ('#TRIM(form.filename)#') and that didn't work either.

    Any ideas on what I'm doing wrong?

    Thank you in advance for your help.



    <cfquery name="addProduct" datasource="southshore">
    INSERT
    INTO PRODUCTS_TEST
    (FILENAME,
    NUMBER,
    TITLE,
    CATEGORY,
    DESIGNER,
    BUILDER,
    COLLECTION,
    DESCRIPTION,
    DIMENSIONS,
    ACTIVE)
    VALUES
    ('#form.filename#',
    '#form.number#',
    '#form.title#',
    '#form.category#',
    '#form.designer#',
    '#form.builder#',
    '#form.collection#',
    '#form.description#',
    '#form.dimensions#',
    '#form.active#')
    </cfquery>

    Jess930 Guest

  2. #2

    Default Re: Trouble with INSERT statement

    NUMBER is a database keyword
    JMGibson3 Guest

  3. #3

    Default Re: Trouble with INSERT statement

    It all looks fine from here! Try taking out the opening and closing cfquery tags and replace then with cfoutputs. Then you can see what is there and you might find your answer!
    Stressed_Simon Guest

  4. #4

    Default Re: Trouble with INSERT statement

    That was the problem--I commented out that field and it worked.

    Now I have a bigger problem--a lot of stuff on my website is dependent on that
    field. Is my only option renaming it in the database?

    Thank you.

    Jess930 Guest

  5. #5

    Default Re: Trouble with INSERT statement

    It is usually better to rename the field, but if you absolutely cannot do that,
    you should be able to escape the column name by adding square brackets around
    the column name.

    INSERT INTO TABLENAME...( ... , [NUMBER], .....) ....

    mxstu Guest

Similar Threads

  1. Question Insert from ASP to SQL using recordset data as values in insert statement
    By JasonM in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: June 13th, 05:54 PM
  2. Trouble with LIKE statement
    By Dionubis in forum Coldfusion Database Access
    Replies: 11
    Last Post: October 8th, 05:53 AM
  3. Help with INSERT INTO statement
    By s_jancich in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: July 20th, 04:39 PM
  4. Replies: 3
    Last Post: September 30th, 09:24 PM
  5. Insert Statement help
    By ksbrace in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: June 30th, 02:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139