Forums

Give help. Get help.

  • # October 4, 2012 at 10:36 am

    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?

    # October 4, 2012 at 9:14 pm

    Thanks I’ll give it a try.
    I’m not a php expert either if you couldn’t tell.:)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag