i don't realy understand a lott of your code. most of it is pointless (closing the connection at the end, storing the linkID without using it, running a select without using the result, storing the time in a variable) + you don't have any debugging included. Below code would result in exactly the same as yours, but is easier to debug
maybe try it like that. + it might help to be a bit more informative then 'my mysql is not working'
$link = mysql_connect("192.168.2.7","myspace_aim","*****") or die('Unable to connect to db-server');
mysql_select_db("myspace_aim") or die('Unable to select db');
$sql = "INSERT INTO `users` ( `mid` , `ausr` , `when` ) VALUES ('$ref', '$username', '". time() ."')";
mysql_query($sql, $link) or die('Unable to execute query: '. $sql . '<br />Error:' . mysql_error());