Yes, but something is having an effect.
When you initialize mysql_select_db() you are changing the default database.
It's the $db
When you use that in mysql_select_db($db,$link) you are making the new database the default for vbulletins $db.
Try this
PHP Code:
$link = mysql_connect($host,$user,$password);
mysql_select_db('database_name',$link);
$result = mysql_query("SELECT * FROM user,rankings where user.userid = '" . $post['foeuserid'] . "' AND user.userid = rankings.user_id Limit 1", $link);
mysql_close($link);