How to access custom WordPress database tables

Are you sure that’s the table name? Usually on install WordPress prompts you to setup a table prefix so the default isn’t wp_.

Additionally, you need to call the global $wpdb object so it’s accessible to use:

global $wpdb;
$user_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users" );
echo "<p>User count is {$user_count}</p>";

Finally, to prevent the prefix issue you can call $wpdb->prefix:

global $wpdb;
$user_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}users" );