Unique fields, grabbing errors
| From: | Jason Gerfen | Date: | Fri, 07 Apr 2006 17:28:40 +0000 |
| Subject: | Unique fields, grabbing errors | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-41666@lists.php.net to get a copy of this message | ||
I am having a problem trying to use 3 unique fields in a database table and grabbing the errors that may result, any help is appreciated.
$update = @mysql_query( "UPDATE hosts SET hostname='$host', mac='$mac', ip='$ip', vlan='$vlan', group='$group' WHERE hostname=\"$host\"", $db );
$error = @mysql_error( $update );
@preg_match( "/\'(.*)\'/", $error, $matches );
$find = @mysql_query( "SELECT * FROM hosts WHERE hostname = '$matches[0]' OR mac = '$matches[0]' OR ip = '$matches[0]'", $db );
$checks = @mysql_num_rows( $find );
if( ( $checks == 1 ) && ( !empty( $error ) ) ) {
...
} else {
...
}
--
Jason Gerfen
"You will never be ready for me."
~ Me