Ti suggerisco di iniziare leggendo il manuale ufficiale:
http://www.php.net/mysql_query Example #1 Invalid Query
http://dev.mysql.com/doc/refman/5.0/...html#id1781585
http://dev.mysql.com/doc/refman/5.0/...ting-rows.html
P.S.
Non usare lo short open tag, utilizza il tag di apertura completo.