Problem with inserting into MySQL

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Problem with inserting into MySQL

    Hi, working with CF 7.1 and MySQL 5. I am using the insert form function in DW
    and have a problem with inserting multiple records into the same auto increment
    record ID. I am using multiple pages to insert image locations into the DB and
    attempting to use the same ID variable passed from page to page. My problem is
    that the auto increment record ID is only allowing the first record to be
    inserted then it creates another record ID for the second insertion and another
    for the third insertion. I want all of the image locations for that record ID
    to go into fields in that one record ID, not create separate records.

    Any help would be great.

    Thanks

    Shane

    Shane930 Guest

  2. Similar Questions and Discussions

    1. inserting date into MySql Database
      I am trying to insert the current date into a MySql database. I know that the date format for MySql is yyyy-mm-dd . So far I have tried to insert...
    2. Inserting Current Date into MySQL Database
      OK, I am a complete Newbie at this, well... almost... I am creating a database that accepts members. I need to know how to insert the date of...
    3. INSERTing Line Breaks into MySQL DB using ASP
      Hi All Could you please let me know how my ASP page can insert 1 row of data containing line breaks into a MySQL DB. To explain, I'm using ASP...
    4. Inserting image into mysql
      hi i created a table and a field with blob datatype. now i want to insert an image into the mysql database. can it be achieved...if yes then...
    5. Sensible Method of Inserting Records In To MySQL
      Hello, I'd appreciate suggestions as I hash out my idea. Perhaps I'm going about this the wrong way. I have users using a third party windows...
  3. #2

    Default Re: Problem with inserting into MySQL

    In almost all cases, having separate records for each image location is the best way to go. But I did say almost. What is your reason for trying to do it all in one record?
    Dan Bracuk Guest

  4. #3

    Default Re: Problem with inserting into MySQL

    Hi Dan, my reason for wanting them all under the same auto increment record ID
    was because I thought it was more efficient. But your question make me wonder.
    Is it really better to have lets say 10 record ID with each image location
    uploaded into separate records? If so and if it doesn't really create an
    inefficient table then another question for you? When I build a recordset to
    display all 10 images by a form variable ad_id, it only displays the first
    image. The recordset works fine in the test mode, all ten records are shown,
    but when I pull the page up I only see the first image with the other nine
    image place holders. I then built another table with all of the image locators
    in the same record ID and the all displayed on the page. So one way the detail
    page only shows one picture and the other way I get 10 records with unique
    record IDs load into the table.

    Thanks for your help

    Shane

    Shane930 Guest

  5. #4

    Default Re: Problem with inserting into MySQL

    My recordset SQL is:

    <cfquery name="photos" datasource="saa">
    SELECT primary_image_path, image_path_1, image_path_2, image_path_3,
    image_path_4, image_path_5, image_path_6, image_path_7, image_path_8,
    image_path_9 FROM saa.photos WHERE ad_id = #FORM.ad_id#
    </cfquery>

    Shane


    Shane930 Guest

  6. #5

    Default Re: Problem with inserting into MySQL

    Having a separate record for each file location gives you a lot more
    flexibility. It also makes it easier to retrieve the records, your present
    difficulties notwithstanding.

    I notice from your query that your table has an awful lot of fields. What are
    your business rules? Can two ads use the same image path?

    Dan Bracuk Guest

  7. #6

    Default Re: Problem with inserting into MySQL

    Hi Dan, I am working on a auto site project as a way to learn DW, CF, MySQL and
    Web design. The site would allow users to upload pictures of their cars with
    up to 10 photos per user. The table for photos has an auto increment
    field(PK), an ad_id which ties the images to the user table and 10 image
    fields, 1-10. To answer your question "Can two ads use the same image path?"
    the answer would be no. So when I upload 10 images now I get 10 separate
    records each with one image path and all have the same ad_id. Is this the best
    way to do the images or should they be all in one record 1-10? Either way is
    fine with me, I was just looking to keep the table clean and efficient for
    rapid retrieval of the images, especially if their were a thousand users. The
    displaying of the images is also another problem that is perplexing. But that
    is another post, lol.

    Thanks again for your input Dan, I appreciate it.

    Shane

    Shane930 Guest

  8. #7

    Default Re: Problem with inserting into MySQL

    A separate record, each having the same ad_id and diffferent image paths is the
    way that I would do it. Depending on the overall schema, I might also not have
    the autoincrement field at all. I would use the ad_id and image path as the
    primary key.

    Dan Bracuk Guest

  9. #8

    Default Re: Problem with inserting into MySQL

    Hi Dan, thanks for the input.

    I figured out what I was doing wrong. I was using the insert record behavior
    for all 10 upload pages when I should have used one insert record page and 9
    update record pages. The update record behavior has a check box for the
    primary key so you can add to the record in the table.

    Now the correct fields are updated and the page displays all of the images not
    just one.

    Take care

    Shane

    Shane930 Guest

Posting Permissions

  • You may not post new threads
  • You may 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