The problem is how you are building your INSERT query. Each value needs to be enclosed in single quotes (except columns that are integers, doubles, floats and decimals), and because you are not including these quotes in the string, the last value of " " is causing a syntax error with your query. Your query looks like this:
INSERT INTO tablename (name,type,size) VALUES (Y,1,)
It needs to look like this:
INSERT INTO tablename (name,type,size) VALUES ('Y','1',' ')
Whenever you run into a syntax error like this, echo out the _actual_ query (the string where you've put all the variables in) and the error will most likely jump right out at you.
$query = "INSERT INTO " . $gradetable . " (name,type,size) VALUES (" . $name . "," . $type . "," . $size . ")";
$table = mysql_query($query,$connection);
die("SQL Error! Query is $query<br />Error is ".mysql_error());