db_query unknown column on where clause?
If you're new to Drupal or PHP coding, you've created a nice example of how not to write an sql query. What you've written is open to SQL-Injection.

Please review the Database API Examples Documentation page.

A "correct" way to write this query using the API could look like (adapting 1 of the top examples to your code) the following.

$result = db_query("SELECT id from {galleries_types} WHERE name = :name", array(':name' =&gt; $form_state['values']['id']));


You will want to make use of placeholders in PDO to write your queries.