For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > April 2006 > Unique fields, grabbing errors









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Unique fields, grabbing errors
Jason Gerfen

2006-04-07, 6:57 pm

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com