I’m writing a plugin that posts data to the WordPress database.
For the most part I have the basics working. I’m using this to check for duplicate entries.
$duplicate = $wpdb->get_results("SELECT * FROM wp_flr_locations WHERE location_name = '{$location_name}'");
if (isset($_POST)) {
if ($duplicate != '') {
$wpdb->insert( 'wp_flr_locations', array( 'location_name' => $_POST ) );
} else {
echo'No Duplaicates Allowed
';
}
}
This does prevent duplicate entries from being posted to the database. The problem I'm having is I want an error message to show if it is duplicate. The "else" doesn't seem to work.
Any Ideas?