This is the sample table :

CREATE TABLE contacts
(
  id character varying NOT NULL,
  CONSTRAINT pkey_id PRIMARY KEY (id)
)

I use PHP with PostgreSQL database..if i will run my PHP code:

Example: ADD ID NUMBER <-- If i will click this, the message below will appear:

Warning: pg_query() [function.pg-query]: Query failed: ERROR: duplicate key value violates unique constraint "pkey_id" in ......

1. I can add id number.
2. I cannot add if duplicate id #'s...
3. I am really confused, why that the message appear even though i am not still adding id number?

Recommended Answers

All 2 Replies

Member Avatar for diafol

This is a database question or pHp?
Show the code for add id number:

I use PHP with PostgreSQL database..if i will run my PHP code:

Example: ADD ID NUMBER <-- If i will click this, the message below will appear

What query are you running?

Thanks by the way. I found out that there is a code there that shows the error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.