Results 1 to 4 of 4
Nov 15, 2000, 12:15 #1
- Join Date
- Nov 2000
- 0 Post(s)
- 0 Thread(s)
Having been through the excellent PHP / MySQL tutorial at webmasterbase.com, I'm now dangerous.
Have a table "Categories" in my MySQL database, which has two columns; ID (INT NOT NULL AUTO_INCREMENT PRIMARY KEY), Category (TEXT).
From a PHP form, want to prevent duplicate entries in the Category column (i.e. the same text string) being inserted into the table.
From the PHP form, the MySQL command I'm using is;
"INSERT INTO Categories SET Category=$cat"
where $cat is a PHP variable.
Is there a way to enhance this command to get it to ignore the INSERT if there is already an entry with the same string as $cat?
"INSERT IGNORE INTO Categories SET Category=$cat"
but this doesnt work (my guess because it checks for a duplicate ID value as well ? ).