WordPress has ton a lot of cool things to simplify the life of a developer. One of those things is to facilitate the whole mysql connection.
so, to begin usage, we set the variable as global:
global $wpdb;
once we initialize as WP likes it, then we can use it:
$queries = $wpdb->get_results("SELECT * FROM test"); foreach ($queries as $query) { echo $query->field; }