Duplicate entry '' for key 2

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Duplicate entry '' for key 2

Post by shawngoldw »

and what happened when you did that? Was everything normal or not?
bian101
Forum Newbie
Posts: 19
Joined: Fri Aug 20, 2010 9:05 am

Re: Duplicate entry '' for key 2

Post by bian101 »

Yep all perfectly normal. Im talking to my lead programmer and he thinks it could be something to do with the primary key, but we are stumped!
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Duplicate entry '' for key 2

Post by shawngoldw »

What field are you using for your primary key? And what attributes does it have? Is it auto increment?
bian101
Forum Newbie
Posts: 19
Joined: Fri Aug 20, 2010 9:05 am

Re: Duplicate entry '' for key 2

Post by bian101 »

shawngoldw wrote:What field are you using for your primary key? And what attributes does it have? Is it auto increment?
Primary key are:

Address
Website
Description

(dont know why there primary)

and auto increment is:
ID.

Hope this helps ;) ( ps im in london today and tommorow so i may not reply until tomorrow.
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Duplicate entry '' for key 2

Post by shawngoldw »

I assume that the composite primary key is also set to be unique?

When you were saying that it works for you and not everyone else, I assume you were always the first to try? When you insert into your database you do not set any of those 3 fields. If they are supposed to be unique, then that explains it telling you the key is a duplicate since somebody being inserted after you is given the same default values for address, website, and description.

Does this sound right?


Also, that seems like an odd choice for your primary key, if you have an auto increment id that is what is generally chosen to be the primary key. I don't know your exact situation and database schema so I can not tell you what your doing is not right though.

London england or ontario?


Shawn
Post Reply