I advise you to catch the error that mysql can return on processing your query
$result = mysql_query($sql) or die('Error :' . mysql_error().'<br>'.$sql);
Typically, PHP doesn't display syntax error returned by the mysql server, so when you try to fetch from the result of a query that failed (it's different from not retunrnig any rows 🙂) all that PHP is able to tell you is that $result is not a valid result id (in fact I bet it is set to false)...
Well, just print the error with mysql_error() and you should be able to debug your query ...
good luck