A solution might be to summon wpdb, before defining the constant: global $wpdb; I assume your problem is caused by the different scope that the plugin is activated in. -- http://scribu.net