Gli apici attorno alle variabili, in ogni caso:

$result=mysql_query($query,$db) or die(mysql_error());