Hmm I don't know exactly what the problem is. How about hard coding the username and userid in the script and seeing if it works that way. I don't see why the vB code isn't working so its best to start from the beginning and work through to identify the problem.
Also try running this on your script and checking if the username returned matches $uname.
PHP Code:
//$uid = $_GET['uid'] ...
$userinfo = fetch_userinfo($uid);
var_dump($userinfo['username'], $uname);
exit();