Make $wpdb global. props @golderweb