I try to count the number of roles in my Drupal database and with the result execute another statement. But for some reason, it’s failing. What do I do wrong?
$numberofroles = db_query('SELECT COUNT(rid) FROM {role}');
$roles = 1;
while ($roles < $numberofroles) {
db_query('INSERT INTO {taxonomy_access_default} (vid, rid, grant_view, grant_update, grant_delete, grant_create, grant_list) VALUES(0, '.$roles.', 1, 0, 0, 0, 1)');
$roles++;
}
You forget a? ->fetchField() ?
Drupal6:
$val = db_result(db_query({...}))Drupal7:
$val = db_query({...})->fetchField();