You are here

function db_result in Drupal 6

Same name in this branch
  1. 6 includes/ \db_result()
  2. 6 includes/ \db_result()
  3. 6 includes/ \db_result()
Same name and namespace in other branches
  1. 4 includes/ \db_result()
  2. 4 includes/ \db_result()
  3. 4 includes/ \db_result()
  4. 5 includes/ \db_result()
  5. 5 includes/ \db_result()
  6. 5 includes/ \db_result()

Return an individual result field from the previous query.

Only use this function if exactly one field is being selected; otherwise, use db_fetch_object() or db_fetch_array().


$result: A database query result resource, as returned from db_query().

Return value

The resulting field or FALSE.

Related topics

116 calls to db_result()
actions_function_lookup in includes/
Given an md5 hash of a function name, return the function name.
aggregator_block in modules/aggregator/aggregator.module
Implementation of hook_block().
block_add_block_form_validate in modules/block/
block_admin_configure_validate in modules/block/
block_flush_caches in modules/block/block.module
Implementation of hook_flush_caches().

... See full list


includes/, line 183
Database interface code for MySQL database servers using the mysqli client libraries. mysqli is included in PHP 5 by default and allows developers to use the advanced features of MySQL 4.1.x, 5.0.x and beyond.


function db_result($result) {
  if ($result && mysqli_num_rows($result) > 0) {

    // The mysqli_fetch_row function has an optional second parameter $row
    // but that can't be used for compatibility with Oracle, DB2, etc.
    $array = mysqli_fetch_row($result);
    return $array[0];
  return FALSE;