If I ever get that error again in my life it will be too soon.
But I'm about to write another script, so it will be too soon 😉
Feeling like an expert on that frickin' error, it means that your mysql_query returned false.
First, right after your mysql_query, echo out $result. If it doesn't say something like "Resource id 2", there is something wrong in your query.
Before you assign your query to $sql, echo out the variables that you are going to make part of $sql (sepperate all the echo's with a "<BR>" so you can easily see what variable is what).
Then after that assign the variables to $sql as you are doing, then echo out $sql before the mysql_query call.
If that STILL doesn't give you the information you need, use this right after your query call:
printf ("MySQL Error: %s\n", mysql_error ());
Beyond that ensure that your table name and column names are valid.
If none of this gives you something interesting to chew on, use your computer as a kufu (meditation pillow) and become a luddite 😉