if you want to debug this you should try to add something like this:
$q2 = \"select type from user where id =
IF (!$Q2) ECHO "ERROR";
$i6token[uid]\";
$result2 = mysql_query($q2,$i6link);
IF (!$RESULT2) ECHO "ERROR";
while($row2 = mysql_fetch_array($result2))
{
echo$row2[\"type\"];
}
This will give you an idea where your mistake took place