WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im trying to update into another table the values blogname, blog description options when the user updated them from General Settings page.

I use this code,

$hook_array = array('update_option_blogname','update_option_admin_email','update_blogdescription','update_option_home','update_option_siteurl');

foreach($hook_array as $hook)
    add_action($hook, 'my_functione', 10, 1);


function my_functione($arg)
    global $wpdb;
    $the_id = get_current_blog_id();
    $blogname =  get_option('blogname'); 
    $blogdescr =  get_option('blogfulldescription');
    $wp_blogs_info = $wpdb->base_prefix . "blogs_info";

    $wpdb->query("UPDATE " . $wp_blogs_info . " SET site_title=".$blogname.", site_description=".$blogdescr." where blog_id = '" . (int)$the_id . "'");


Here is the table,

  blog_id int NOT NULL,
  countries_id int(3) NOT NULL,
  site_title varchar(64) NOT NULL,
  site_description varchar(64) NOT NULL,
  site_tags varchar(64) NOT NULL,
  PRIMARY KEY (blog_id)

However, its not updating though there is a value with the blog_id of the current blog.. Please help.

share|improve this question
what is the outcome? do you get any error or message? – HungryCoder Jun 19 '12 at 7:12
up vote 0 down vote accepted

well, i just found that you've error in your query. i've re-written that for you:

$wpdb->query("UPDATE `" . $wp_blogs_info . "` SET `site_title`='".$wpdb->escape($blogname)."', `site_description` = '".$wpdb->escape($blogdescr)."' where blog_id = '" . (int)$the_id . "'");
share|improve this answer
Thank you! it works now. I didn't knew the escape one. – Ken Jun 19 '12 at 7:56
not only escaping, you did not put the quotation sign around the values. – HungryCoder Jun 19 '12 at 8:27
I see.. Thanks again.. – Ken Jun 19 '12 at 12:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.