As the error message states, you're referencing a variable called $square but you didn't define it anywhere.
If $square is supposed to come from external data (e.g. the query string, a form submission, etc.), then you have to use the appropriate superglobal array ($GET, $POST, etc.). See this manual page for more information: [man]variables.external[/man].
Also, your SQL query isn't formed correctly either. Your WHERE condition contains a single string; if you instead meant to compare the column "square" to a string value, then the single quotes should be around the string value only. It's the same concept as in PHP... would you write this:
'$variable = value here;'
or this:
$variable = 'value here';
EDIT: Also note that user-supplied data should never be placed directly into a SQL query, else you'll be vulnerable to SQL injection attacks (and/or just plain SQL errors). Instead, it must first be sanitized with a function such as [man]mysql_real_escape_string/man.
EDIT2: In addition, you aren't processing the SQL result set correctly. Here is where you retrieve information from all of the rows matched:
for ($i = 0; $i < $numOfRows; $i++){
$piece = mysql_result ($result, $i, "piece");
}
That loop will run, overwriting the value each time until the loop ends, leaving you with the last row. Instead, you should move the code that deals with each row inside the loop.