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.

  • what is the outcome? do you get any error or message? Commented Jun 19, 2012 at 7:12

1 Answer 1


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 . "'");
  • Thank you! it works now. I didn't knew the escape one.
    – Ken
    Commented Jun 19, 2012 at 7:56
  • not only escaping, you did not put the quotation sign around the values. Commented Jun 19, 2012 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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