db_query not returning anything (or empty) - drupal 7
The return from db_query() is a resource that you can iterate over, it's never a single value.

The way to get a single field from a query is with the fetchField() method:

$result = db_query('SELECT name FROM {users} WHERE uid = 1')-&gt;fetchField();


If you've got more than one result then you can iterate over it like so:

foreach ($result as $row) {
  // Do something with $row...
}


or, you can make use of one of the helper methods to get data directly from the query into a local variable. These include:


fetchObject()


  Fetches the next row and returns it as an object.

fetchAllAssoc()


  Returns the result set as an associative array keyed by the given field.

fetchAllKeyed()


  Returns the entire result set as a single associative array.

fetchAssoc()


  Fetches the next row and returns it as an associative array.

fetchCol()


  Returns an entire single column of a result set as an indexed array.

fetchField()


  Returns a single field from the next record of a result set.