PDA

View Full Version : Help me set usergroupid to a custom user field


Galen
08-06-2002, 09:12 PM
Take a look at the second-to-last line (DB_site).


// ###################### Start do moderate and coppa #######################
if ($HTTP_POST_VARS['action']=="domoderate") {

while (list($key,$val)=each($validate)) {
if ($val==1) {

$user=$DB_site->query_first("SELECT username,email FROM user WHERE userid=$key");
$username=unhtmlspecialchars($user[username]);

eval("\$message = \"".ereg_replace("\"","\\\"",$email)."\";");
eval("\$subject = \"".ereg_replace("\"","\\\"",$subject)."\";");

mail ($user[email],$subject,$message,"From: $webmasteremail");

$DB_site->query("UPDATE user SET usergroupid=2 WHERE userid=$key");
}
}

echo "<p>Accounts validated and users notified</p>";

}


Where it says SET usergroupid=2, I would like instead for it to set the usergroupid to a custom user field number that is selected at registration.

So, instead of SET usergroupid=2, I'd like it to say, SET usergroupid=field8.

Except, this doesn't work - I don't know how to properly insert the value of field8 into usergroupid. Any suggestions?

Xenon
08-07-2002, 06:53 PM
replace this:$DB_site->query("UPDATE user SET usergroupid=2 WHERE userid=$key");

with this:
$fields=$DB_site->query_first("SELECT field8 FROM userfields WHERE userid=$key");
$DB_site->query("UPDATE user SET usergroupid=".$fields[field8]." WHERE userid=$key");

should work, but be carefull, because the can became admins when field8 == 6 so i'd add an ifclause before ;)

Galen
08-08-2002, 04:27 AM
But... it didn't work.

Here's the error message:


Database error in vBulletin Control Panel 2.2.6:

Invalid SQL: SELECT?field8?FROM?userfields?WHERE?userid=1188
mysql error: You have an error in your SQL syntax near 'SELECT?field8?FROM?userfields?WHERE?userid=1188' at line 1

mysql error number: 1064


Thank you for helping me. Do you know how to fix this?

Galen
08-08-2002, 04:29 AM
by the way, my registration form is edited so that users can only select from a menu of values - and admin's not on there!

My URL is http://www.zbths.net/noiz/register.php - if that can help you.

Xenon
08-08-2002, 11:15 AM
look at the errormessage, you've uploaded a corrupted file, be sure you upload an ascii file

as you can see all spaces have been converted to an Ê, redo this change

Galen
08-10-2002, 03:18 AM
The rest of user.php still works... but when I go to process my users (aka, set usergroupid=field8), I get the error message, and an e-mail with the corrupted-looking characters.

Any idea?

Thank you so much.

-galen

Xenon
08-10-2002, 12:48 PM
yes it is corrupted, perhaps you use an editor which corrupts the file at the edited lines.

try to use notepad instead

Galen
08-13-2002, 07:27 PM
but here's the new error message:


Database error in vBulletin Control Panel 2.2.6:

Invalid SQL: SELECT field8 FROM userfields WHERE userid=1188
mysql error: Table 'zbths_net.userfields' doesn't exist

mysql error number: 1146


Thank you.

-galen

Galen
08-13-2002, 07:37 PM
Nevermind! I found the problem - you had added an "s" to userfield.

Thank you for your help. You rock!

Is there a way I can commend you?

-galen

Xenon
08-13-2002, 10:41 PM
damn typings ;)

It's my job to help people here :)