You need `global $CONFIG;` above. This bit me upgrading a db with prefix = `elgg_`.