Your initial question is not using a placeholder for the table name -- you are attempting to interpolate a variable to get the table name into a string which is then passed to the prepare routine. This is not working as you expect because you are using single quotes ( as stated by the previous posters ).
in reply to Re: Variable table
in thread Failure plugging table into into query
Make your line look like this instead and it should work:
$sth = $db->prepare("SELECT Names FROM $table WHERE Name = ?");