Update get_channels to leave out undefined

Undefined channel was defaulted in the channel list, and I didn’t like
that, so I updated the SQL query using pg_query() and
pg_escape_string().