Connect to MySQL with variables

hey all,
I’m having a problem that i didn’t know would be one. I’m trying to connect to a mySQL table determined by variables from an html form. Basically, I have an html form with a input box with the name “town”. On submit, the variables are passed to a php script as follows:

$link = mysql_connect("localhost", "clients", "password");
mysql_select_db("$state", $link);
$result = mysql_query("SELECT name,category FROM $town WHERE (name='$name') AND (category='$category')");

as you can see i’m trying to connect to a specific state database, from which i will select the table specified with the $town variable. I’ve replaced $town with the actual town name to ensure that the table works and it does. So the problem comes when i try to use $town to denote the table i wish to open. I’ve also tried using ‘$town’ and (’$town’). Anyone have any suggestions???