Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Hi,

    I'm trying to update my blog with the following query:

    Code:
    INSERT INTO `journal` ( `id` , `title` , `type` , `date` , `year` , `month` , `day` , `description` , `main` , `category` , `directory` , `visibility` ) 
    VALUES ( '128', 'Stephen Fry Book Synopsis', 'note', '2005-11-10 02:21:55', '2005', '11', '10', '<p> I thought the synopsis of Stephen Fry\'s Ti... </p> ', '<p> I thought the synopsis of <a href=\"http://www.stephenfry.com\">Stephen Fry</a>\'s <em><a href=\"http://www.amazon.co.uk/exec/obidos/ASIN/1840244666/ref=pd_bxgy_img_2_cp/026-4396765-9207609\">Tish and Pish</a></em> on Amazon was too good not to share: </p> <blockquote cite=\"http://www.amazon.co.uk/exec/obidos/ASIN/1840244666/ref=pd_bxgy_img_2_cp/026-4396765-9207609\"> <div class=\"quote\"> The English tongue has never tasted more delicious than in the mouth of Stephen Fry: his chokingly brilliant sesquipedalian prose is like a shaft of sunlight through the drizzle of quotidian language. Now, with this bound monograph, we can all emit a similarly exquisite effulgence and enjoy the bright shaft of Stephen Fry locution in the privacy of our own smallest pavilion. May his shaft continue to pleasure us for many years to come. After all, what could be fluffier? </div> <div class=\"source\"> - <a href=\"http://www.amazon.co.uk/exec/obidos/ASIN/1840244666/ref=pd_bxgy_img_2_cp/026-4396765-9207609\">Amazon Book Synopsis</a> </div> </blockquote>', 'humour', 'frysynopsis', 'visible'
    )

    But whenever I do I get this message from MySQL:


    #1062 - Duplicate entry '127' for key 1

    At first, in my query, the ID field was left to '', so it would auto-increment. But then when it said this I figured it was just a problem with the auto-incrementing, so I put in '128' manually.


    But it still says it.


    Why does it still tell me there's a duplicate mysql entry when I'm specifying a different ID? Help please


    Thanks a bundle.
    tekp :cheeky: tekponline.com

  2.  

  3. #2
    Senior Member Stylise's Avatar
    Join Date
    Jul 2005
    Location
    Mount Martha, Australia
    Posts
    229
    Member #
    10679
    is the id the only field you have a key/index on?

  4. #3
    Senior Member jbagley's Avatar
    Join Date
    Sep 2004
    Location
    Cape Town
    Posts
    845
    Member #
    7422
    take out the ID from your insert completely...

    Code:
    INSERT INTO `journal` ( `title` , `type` , `date` , `year` , `month` , `day` , `description` , `main` , `category` , `directory` , `visibility` ) 
    VALUES ('Stephen Fry Book Synopsis', 'note', '2005-11-10 02:21:55', '2005', '11', '10', '<p> I thought the synopsis of Stephen Fry\'s Ti... </p> ', '<p> I thought the synopsis of <a href=\"http://www.stephenfry.com\">Stephen Fry</a>\'s <em><a href=\"http://www.amazon.co.uk/exec/obidos/ASIN/1840244666/ref=pd_bxgy_img_2_cp/026-4396765-9207609\">Tish and Pish</a></em> on Amazon was too good not to share: </p> <blockquote cite=\"http://www.amazon.co.uk/exec/obidos/ASIN/1840244666/ref=pd_bxgy_img_2_cp/026-4396765-9207609\"> <div class=\"quote\"> The English tongue has never tasted more delicious than in the mouth of Stephen Fry: his chokingly brilliant sesquipedalian prose is like a shaft of sunlight through the drizzle of quotidian language. Now, with this bound monograph, we can all emit a similarly exquisite effulgence and enjoy the bright shaft of Stephen Fry locution in the privacy of our own smallest pavilion. May his shaft continue to pleasure us for many years to come. After all, what could be fluffier? </div> <div class=\"source\"> - <a href=\"http://www.amazon.co.uk/exec/obidos/ASIN/1840244666/ref=pd_bxgy_img_2_cp/026-4396765-9207609\">Amazon Book Synopsis</a> </div> </blockquote>', 'humour', 'frysynopsis', 'visible'
    )

  5. #4
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Yeah it is, and ok I'll try that, cheers.

    Edit: Okay, I tried it, but it's still giving the same message.

    Is is a problem with my server, d'you reckon?

    And also, if I just leave out things like that in queries will they just be inserted as blanks unless have an auto-increment? Thanks.
    tekp :cheeky: tekponline.com

  6. #5
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Yes, if you leave out a auto increment column they will be added for you.

    Leaving out say a VARCHAR will invoke null unless you have a default value I believe.

  7. #6
    Senior Member jbagley's Avatar
    Join Date
    Sep 2004
    Location
    Cape Town
    Posts
    845
    Member #
    7422
    tekp, is the id field an auto-increment? If not, make it auto-increment and then try my sql command.

    Another thing, post the result of this sql to us. Maybe its the table structure.
    Code:
    describe journal;

  8. #7
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Quote Originally Posted by bfsog
    Yes, if you leave out a auto increment column they will be added for you.

    Leaving out say a VARCHAR will invoke null unless you have a default value I believe.
    Ah right, thanks ^_^

    jbagley, it does have an auto-increment on it.

    I'll post the results of that query once I'm back home and have access to my cpanel (I'm currently at school).

    Thanks for your help so far
    tekp :cheeky: tekponline.com

  9. #8
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Ok, here's the results (attached).

    Sorry I took so long to reply, I really appreciate your help; it's really starting to bug me now...

    Thanks again
    Attached Images Attached Images
    tekp :cheeky: tekponline.com

  10. #9
    Senior Member jbagley's Avatar
    Join Date
    Sep 2004
    Location
    Cape Town
    Posts
    845
    Member #
    7422
    Thats really weird. Normally on an auto-increment field, you never nead to enter it into the SQL in order for a new ID to be generated.

    How do you normally update your journal? Using sql commands? Im sure you have an interface you are using....

    Print this code for us plz. No need for a screenshot, just post the results here.
    Code:
    SELECT id FROM journal

  11. #10
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    How do you normally update your journal? Using sql commands? Im sure you have an interface you are using....
    Heavens no, I update my journal with a home-made CMS (*is proud*)

    It forms a big query and inputs the data, the query I originally posted was one of these queries.

    What do you mean 'post the results here'? Like so?

    (The Edit and Deletes are the alts of images)
    --------------id
    Edit Delete 42
    Edit Delete 45
    Edit Delete 46
    Edit Delete 67
    Edit Delete 72
    Edit Delete 73
    Edit Delete 74
    Edit Delete 75
    Edit Delete 76
    Edit Delete 89
    Edit Delete 90
    Edit Delete 91
    Edit Delete 92
    Edit Delete 93
    Edit Delete 94
    Edit Delete 95
    Edit Delete 96
    Edit Delete 97
    Edit Delete 98
    Edit Delete 99
    Edit Delete 100
    Edit Delete 101
    Edit Delete 102
    Edit Delete 103
    Edit Delete 104
    Edit Delete 105
    Edit Delete 106
    Edit Delete 107
    Edit Delete 108
    Edit Delete 109
    Edit Delete 110
    Edit Delete 111
    Edit Delete 112
    Edit Delete 113
    Edit Delete 114
    Edit Delete 115
    Edit Delete 116
    Edit Delete 117
    Edit Delete 118
    Edit Delete 119
    Edit Delete 120
    Edit Delete 121
    Edit Delete 122
    Edit Delete 123
    Edit Delete 125
    Edit Delete 126
    Edit Delete 127
    Thanks again for your help, I'd have given up now if I were you :P
    tekp :cheeky: tekponline.com


Remove Ads

Posting Permissions

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

Search tags for this page

duplicate entry 1 for key fk fieldmaster 1

Click on a term to search for related topics.
All times are GMT -6. The time now is 03:14 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com