Title: Using table_prefix for multiple blogs
Last modified: August 19, 2016

---

# Using table_prefix for multiple blogs

 *  [msolution](https://wordpress.org/support/users/msolution/)
 * (@msolution)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/using-table_prefix-for-multiple-blogs/)
 * my objective is to use a single wp installation for various blogs.
    and i need
   to do this with wp, not wpmu.
 * following is my code:
 *     ```
       if(!$_SESSION)	session_start();
   
       if(isset($_GET['blog']) && $_GET['blog'] != ''){
       	$blog = trim(strip_tags($_GET['blog']));
       	$table_prefix  = $_SESSION['table_prefix'] = 'wp_'.$blog.'_';
       	header('Location: http://ww.dir.vc/demo/'); //back to same URL without the ?...
       	exit;
       } else if(isset($_SESSION['table_prefix'])) {
       	$table_prefix  = $_SESSION['table_prefix'];
       } else {
       	die('no blog found');
       }
       ```
   
 * it does register table_prefix,…gets redirected to an absolute URL, and then shows
   me a blank page

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

 *  Thread Starter [msolution](https://wordpress.org/support/users/msolution/)
 * (@msolution)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/using-table_prefix-for-multiple-blogs/#post-1538872)
 * **UPDATE**: this issue is a possible bug with 3.0,
    the above works with wordpress
   2.9.2
 *  [Austin Matzko](https://wordpress.org/support/users/filosofo/)
 * (@filosofo)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/using-table_prefix-for-multiple-blogs/#post-1538979)
 * Your code introduces a potentially serious security vulnerability by allowing
   the public to set the tables’ prefix to an arbitrary string.
 *  Thread Starter [msolution](https://wordpress.org/support/users/msolution/)
 * (@msolution)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/using-table_prefix-for-multiple-blogs/#post-1539108)
 * the above is a cut down version of what im trying to accomplish, didnt want to
   add unnecessary code here.
 * **before putting the variable into a session variable im checking if its a digit,
   and if that id is present in the database.**
 * let me know if this helps, would appreciate, if this is checked, else i would
   have to take my plugin back to the drawing board.
 * M.
 *  [Darrell Schauss](https://wordpress.org/support/users/darrellonsite/)
 * (@darrellonsite)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/using-table_prefix-for-multiple-blogs/#post-1539111)
 * It will probably give you tons of headache the next time the database needs to
   be updated when WordPress gets updated. What about this… _WordPress and WordPress
   MU have merged, allowing the management of multiple sites (called Multisite) 
   from one WordPress installation._ Is this saying that wordpress multisite/multiblog
   functionality is now part of WordPress 3 or that they are collaborating with 
   each other now?

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

The topic ‘Using table_prefix for multiple blogs’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [Darrell Schauss](https://wordpress.org/support/users/darrellonsite/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/using-table_prefix-for-multiple-blogs/#post-1539111)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
