Re: [PHP-DB] multiple fields all unique? [almost solved]

2004-02-04 Thread Jas
Jas wrote: For this table to create 3 unique keys I did the following, in case it helps someone else out. +--+--+--+-+-++ | Field| Type | Null | Key | Default | Extra |

Re: [PHP-DB] multiple fields all unique? [almost solved]

2004-02-04 Thread Jas
If I do this statement: mysql_query(UPDATE hosts SET hostname=\$_POST[hostname]\, mac=\$_POST[mac]\, ip=\$_POST[ip]\, vlan=\$_POST[vlan]\ WHERE id=\$_SESSION[id]\,$db)or die(mysql_error() . mysql_errno()); I get this error: Duplicate entry '128.110.22.139' for key 41062 I have tried using these

Re: [PHP-DB] multiple fields all unique? [almost solved]

2004-02-04 Thread John W. Holmes
From: Jas [EMAIL PROTECTED] for instance, say you change the mac and hostname and there is a record in the database with the same mac string, how can I flag the field that matched from the 3? Your update will actually fail in the case, so you need to catch the error with mysql_error() (and

Re: [PHP-DB] multiple fields all unique? [almost solved]

2004-02-04 Thread Jas
John W. Holmes wrote: [snip] When you update the table with an existing mac value, the error will be similar to Duplicate value for Key XX where XX is what key was duplicated. I can't remember if the keys start at zero or one, but your ID column will be the first key, then mac, hostname, and

Re: [PHP-DB] multiple fields all unique? [almost solved]

2004-02-04 Thread John W. Holmes
From: Jas [EMAIL PROTECTED] If I do this statement: mysql_query(UPDATE hosts SET hostname=\$_POST[hostname]\, mac=\$_POST[mac]\, ip=\$_POST[ip]\, vlan=\$_POST[vlan]\ WHERE id=\$_SESSION[id]\,$db)or die(mysql_error() . mysql_errno()); I get this error: Duplicate entry '128.110.22.139' for

Re: [PHP-DB] multiple fields all unique? [almost solved]

2004-02-04 Thread Jas
[snip] You're not going to be able to fetch anything from the result set because you're excuting an UPDATE query, not a SELECT. You also do not want to die() when the query fails, otherwise you won't be able to react to the error. Execute the query, then check mysql_error() for a value. If it