Unique fields, grabbing errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux