in database structure, i suggest you to use "UNIQUE" key . this will make data insertion more easy.
here is the table example:
CREATE TABLE `color` (
`colorID` TINYINT(3) NOT NULL AUTO_INCREMENT,
`colorName` VARCHAR(50) NOT NULL,
PRIMARY KEY ('colorID'),
UNIQUE (`testName`)
);
by using this structure, you can add entry only by typing this simple script:
if(!mysql_query("INSERT INTO color VALUES ('','color')"))
print "Identical color. Insert 0 row";
else
print "Color added";