Closed (fixed)
Project:
Drupal core
Version:
6.20
Component:
other
Priority:
Critical
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
29 Sep 2009 at 08:32 UTC
Updated:
11 Feb 2011 at 07:19 UTC
Following code not working in our installation of drupal. :
function testform_user($type, &$edit, &$user, $category = NULL) {
switch ($type) {
case 'insert':
$sql = 'INSERT INTO {users_roles} (uid, rid) values (%d, %d)';
db_query($sql, $user->uid, 3);
break;
}
}
The values just will not insert into the database. No error messages, nothing.
If we replace $user->uid with an actual value e.g 'db_query($sql, 124, 3)', the values insert fine.
Have also tried:
$userID=$user->uid;
.
.
$sql = 'INSERT INTO {users_roles} (uid, rid) values (%d, %d)';
db_query($sql, $userID, 3);
This does not work either.
However, this works perfectly on a fresh installation of drupal.
Also, if I create another table, e.g. user_role, this table updates fine with the function.
Could there be a module conflict of some kind? Can give a list of modules installed if required.
Comments
Comment #1
freestylegary@yahoo.com commentedHave isolated the issue to the 'workflow_ng' module. I don't need the module so disabling it fixes it for me. But the question as to why the issue would occur with this module remains...
Comment #3
marashi commentedI think there is a conflict somewhere in the core! maybe the "users_roles" table has been locked for direct access or ..., but I found this solution:
instead of trying to insert a new row in "users_roles" table by:
just let Drupal itself, do it for you by using this code in user('insert') hook: