为什么我收到这个mysql错误? [关闭]

I'm working on a board with members and such. The member system is done and I'm just starting to work on posting. I've got a basic posting page that works: it sends the data to the database. But on the page that is supposed to display the posts, I'm getting this error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in public_html/board/displayposts/stuff/index.php on line 7

Line 7 is is part of code that fetches the URL for the poster's avatar from the database:

$avatarget = mysql_query("SELECT * FROM user WHEN username='$user'");
$getavatar = mysql_fetch_assoc($avatarget); # line 7    

Now normally when I see that error, there's something wrong with the SQL statement. Are there any errors in $avatarget?

$avatarget = mysql_query("SELECT * FROM user WHEN username='$user'");

Should be

$avatarget = mysql_query("SELECT * FROM user WHERE username='$user'");

You're using the incorrect clause:

$avatarget = mysql_query("SELECT * FROM user WHEN username='$user'");

There is no WHEN clause and that should instead be WHERE.