It looks like you are associating a key to a query, instead of running the query. Let me give you an example of how something like this must be done:
// setting $user variable
$user=$_SESSION['username'];
// create the select statement
$select="SELECT id FROM users WHERE username = \"$user\" ";
// now run it
$result=mysql_query($select)
or die("Select statement \"$select\" had errors.");
// Now that we have a result, let's associate the each value returned to a variable
// that is named after the database key (in this case, id becomes $id).
while ($row=mysql_fetch_array($result,MYSQL_ASSOC)
{
//first, we need to extract the data from the next row returned
extract($row);
// then, we need to do something with it, in this case, echo it to the screen
echo "The ID returned is $id. <br />";
}