$previous_database = db_set_active('seperate_db') db_set_active($previous_database); function swap_db_form_alter($form_id, &$form) { // Send profile data to external database. if (isset($form['type']) && 'edit-profile' == $form_id) { if (db_result(db_query("SELECT fid FROM {profile_fields} WHERE username = '%s'". $query_suffix, $args2))) { // Table Insert Stuff } } } db_set_active();