# Local 5.10.1 duplicated database entries

**URL:** https://community.localwp.com/t/local-5-10-1-duplicated-database-entries/24723
**Category:** Support
**Tags:** mac-catalina, mac-big-sur, database
**Created:** [March 7, 2021, 3:34pm UTC](https://community.localwp.com/t/local-5-10-1-duplicated-database-entries/24723 "2021-03-07T15:34:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![vj1221](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/vj1221/32/12738_2.png) [@vj1221](https://community.localwp.com/u/vj1221)
#### Post date: [March 7, 2021, 3:34pm UTC](https://community.localwp.com/t/local-5-10-1-duplicated-database-entries/24723/1 "2021-03-07T15:34:23Z")

</div>

### Issue Summary

When creating custom $wpdb table and custom entries (with wp functions) local creates duplicated entries while it should create only one. For example $wpdb-\>insert(…);  
It only happens on local. Tested on XAMPP and this behaviour does’t happen (both local/xampp ssl https).

Tested with empty theme (only empty style.css, empty functions.php, empty index.php) No plugins installed, brand new site and database.

#### Troubleshooting Questions

- Does this happen for all sites in Local, or just one in particular? All.

- Are you able to create a new, plain WordPress site in Local and access it in a Browser? Yes.

#### Replication

Create these 2 functions in functions.php. (first to create a table, second to create an entry).  
It should creat 1 entry to that table on each page reload. But instead it creates 2 entries in the table.

```
function create_table($table_name){
    global $wpdb;

    $charset_collate = $wpdb->get_charset_collate();
    $table_name = $wpdb->prefix . $table_name;

    $sql = "CREATE TABLE $table_name (
    id int(10) NOT NULL AUTO_INCREMENT,
    user_name varchar(100) DEFAULT '' NOT NULL,
    password varchar(100) DEFAULT '' NOT NULL,
    email varchar(100) DEFAULT '' NOT NULL,
    PRIMARY KEY (id)
    ) $charset_collate;";

    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $sql );
}

create_table('test');

function insert_to_table($table_name){
    global $wpdb;

    $table_name = $wpdb->prefix . $table_name;

    $wpdb->insert( 
        $table_name, 
        array( 
            'user_name' => 'user', 
            'password' => 'pass', 
            'email' => 'myemail',
        ), 
        array( 
            '%s', 
            '%s', 
            '%s',
        ) 
    );
}

insert_to_table('test');

```

#### System Details

- Which version of Local is being used? local 5.10.1

- What Operating System (OS) and OS version is being used? Mac OS 11.2.2 & 10.15.7

- Attach the Local Log. See this Community Forum post for instructions on how to do so:

---

<div class="post-metadata">

### Author: ![vj1221](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/vj1221/32/12738_2.png) [@vj1221](https://community.localwp.com/u/vj1221)
#### Post date: [March 8, 2021, 6:25pm UTC](https://community.localwp.com/t/local-5-10-1-duplicated-database-entries/24723/2 "2021-03-08T18:25:13Z")

</div>

@clay any help to confirm it’s a Local bug? Or that’s something wrong with my configuration?

Meanwhile have to go back to XAMPP.

---

<div class="post-metadata">

### Author: ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/system/32/1_2.png) [@system](https://community.localwp.com/u/system)
#### Post date: [June 6, 2021, 6:25pm UTC](https://community.localwp.com/t/local-5-10-1-duplicated-database-entries/24723/3 "2021-06-06T18:25:14Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
