Title: Multisite Table Prefix &quot;$wpdb-&gt;prefix&quot; incorrect
Last modified: August 19, 2016

---

# Multisite Table Prefix "$wpdb->prefix" incorrect

 *  [jskov](https://wordpress.org/support/users/jskov/)
 * (@jskov)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/multisite-table-prefix-wpdb-prefix-incorrect/)
 * I have upgraded a 2.9.1 wpmu installation to WP 3.0.1 MS.
 * Now, I am having issues with the $wpdb->prefix reference in a few plugins. It
   seems to pull an individual blog’s prefix (ie. wp_#_ ) rather than the site prefix(
   ie. wp_ ).
 * Is this correct? Is there something else that should be used instead? Is there
   something I am missing?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Leon](https://wordpress.org/support/users/leondoornkamp/)
 * (@leondoornkamp)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/multisite-table-prefix-wpdb-prefix-incorrect/#post-1784232)
 * I was just having a similar problem.
 * You can get the variable out of wp-config.php >> $table_prefix
    which is bij 
   default ‘wp_’ So I thought I could be using that as site prefix, but apparantly
   wordpress adds ‘#_’ to this as well…
 * So when you do the following on a plugin:
 *     ```
       global $table_prefix;
       var_dump( $table_prefix );
       ```
   
 * it outputs ‘wp_#_’;
 * But I also need it to output ‘wp_’;
 * hope someone can explain.
 *  [David Gard](https://wordpress.org/support/users/duck_boy/)
 * (@duck_boy)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/multisite-table-prefix-wpdb-prefix-incorrect/#post-1784243)
 * The following will give you just the `wp_` part.
 *     ```
       global $wpdb;
       print_r($wpdb->base_prefix);
       ```
   
 *  [Leon](https://wordpress.org/support/users/leondoornkamp/)
 * (@leondoornkamp)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/multisite-table-prefix-wpdb-prefix-incorrect/#post-1784261)
 * Much appreciated! That does the trick for me!
 *  [David Gard](https://wordpress.org/support/users/duck_boy/)
 * (@duck_boy)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/multisite-table-prefix-wpdb-prefix-incorrect/#post-1784264)
 * No worries – If you are referencing a pre-existing table you can also use the
   $wpdb class to call the name of the table (including the correct base-prefix/
   prefix) For example, on my companies Client Balances site `$wpdb->posts` would
   return ‘wp_2_posts’ and `$wpdb->users` would return ‘wp_users’ – Very handy!
 *  Thread Starter [jskov](https://wordpress.org/support/users/jskov/)
 * (@jskov)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/multisite-table-prefix-wpdb-prefix-incorrect/#post-1784325)
 * Sweet. I’ll give it a try

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Multisite Table Prefix "$wpdb->prefix" incorrect’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [multisite](https://wordpress.org/support/topic-tag/multisite/)
 * [prefix](https://wordpress.org/support/topic-tag/prefix/)
 * [table](https://wordpress.org/support/topic-tag/table/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [jskov](https://wordpress.org/support/users/jskov/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/multisite-table-prefix-wpdb-prefix-incorrect/#post-1784325)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
