The Little Guy Posted May 22, 2011 Share Posted May 22, 2011 I have a mysql unique index on two columns: UNIQUE KEY `page_id` (`page_id`,`tag_id`) I have a mysql query like this: mysql_query("insert into link_tags (page_id, tag_id) values ($page_id, $tag_id)"); If I run that, what would be the best way for php not to fail if the key already exists? within a while loop, would this be best? if(mysql_query("insert into link_tags (page_id, tag_id) values ($page_id, $tag_id)")) continue; Or would the code above (first code) be sufficient enough? Link to comment https://forums.phpfreaks.com/topic/237133-mysql-unique-key-error/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.