Support » How-To and Troubleshooting » Using table_prefix for multiple blogs

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 ?...
    } 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)
  • UPDATE: this issue is a possible bug with 3.0,
    the above works with wordpress 2.9.2

    Your code introduces a potentially serious security vulnerability by allowing the public to set the tables’ prefix to an arbitrary string.

    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.


    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.