$wpdb->insert duplicate entries
-
I’m working on a script that creates a new entry every time a php function is called in order to track how many times an ad has been served.
I’ve created my table using this code:
$adserve_table = "CREATE TABLE $adserve_table_name ( meta_id mediumint(9) NOT NULL AUTO_INCREMENT UNIQUE, ad_id mediumint(9), meta_key varchar(255), meta_value longtext ) CHARACTER SET $charset ;";
and I’m inserting the entry using this code:
$wpdb->insert( $adserve_table_name, array( 'ad_id' => $id, 'meta_key' => 'serve', 'meta_value' => $time ), array( '%d', '%s', '%d' ) );
I’m pretty good with PHP and WordPress, but MySQL is something that I’m just learning and I’m wondering if I’ve coded the insert wrong, or if I’m just bad at MySQL.
I’m pretty sure it’s not going though this insert code, than some other insert code, cause when I change what gets inserted, the change gets inserted twice.
I’m not sure if the code is being ran twice, I only see it once on the page. This is being displayed by using shortcode, has anyone had any issues with that?
The only other thing that I can think of is that it might be a variable is that this is a local installation.
I’d appreciate any help that I can get.
- The topic ‘$wpdb->insert duplicate entries’ is closed to new replies.