jkpalmer52 Posted February 9, 2007 Share Posted February 9, 2007 Newbie here, looking for a code sample. I'm trying to create a web site using PHP - Dreamweaver 2004 MX. I have a MySQL table that has a primary key that is auto_increment but also has an UNIQUE index comprised of two fields on that table. When inserting a row to the table, if MySQL detects that the 2 elements on the UNIQUE index would cause a duplicate key, I'd like to display a message on that form / page rather than taking the Dreamweaver "default" of - die (ing). Is there an example that someone could direct me to that does something like this? TIA - -jP Link to comment https://forums.phpfreaks.com/topic/37790-sql-messages-on-form/ Share on other sites More sharing options...
effigy Posted February 9, 2007 Share Posted February 9, 2007 You can query the database to see if it already exists, or set up a try/catch or Exception class to handle the error. Link to comment https://forums.phpfreaks.com/topic/37790-sql-messages-on-form/#findComment-180776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.