Jump to content

Invalid query error


jf3000

Recommended Posts

Can someone please tell me what this means :

[code]
Invalid query: Duplicate entry '0' for key 1 Whole query:
INSERT INTO add_log ( address, ref, browser) values
( '10.1.1.1','http://blah.blah.blah','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4)

Gecko/20060508 Firefox/1.5.0.4')
[/code]


Ip addy and website have been changed.

I cant seem to understand what this type of error means, thank you.
Link to comment
Share on other sites

IMO (which isn't always perfect) you're trying to insert a repeated "key"...or unique identifier...and the DB is rejecting it.  To avoid errors like this, I usually set up my SQL database with a generic "id" tag that auto-increments...and never try to hard-set it myself. 

Also...you can run with an INSERT INTO .... ON DUPLICATE KEY UPDATE...  if you want to be able to update entries with an identical key that have shown up before...
Link to comment
Share on other sites

Does this table have an auto incrimenting primary key? It should. It sounds like your trying to use one of those fileds as a primary key, and a primary key must be unique.

Adding an auto incrimenting primary key to the field to the table ought fix it.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.