query user display_name failed in a custom mysql query foreach

You should use all of the goodness of the wpdb object.

#Create a new WPDB object for your custom DB
$foo_db = new wpdb('username','password','database','localhost');
$query = ('SELECT * FROM custom_table');

#Use the get_results method - You can return OBJECT(default), OBJECT_K, ARRAY_A, ARRAY_N
$results = $foo_db->get_results($query, OBJECT);
foreach($results as $row){
    $user = new WP_User($row->user_id);
}

You can read more here: http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results

To note, if you are selecting from the same server that uses the same credentials, try the following instead so as not to nest another identical connection:

global $wpdb;
$query = 'SELECT * FROM db_name.custom_table';
$results = $wpdb->get_results($query);

Hope this helps you!