Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 08-06-2002, 09:12 PM
Galen Galen is offline
 
Join Date: Apr 2002
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help me set usergroupid to a custom user field

Take a look at the second-to-last line (DB_site).

Code:
// ###################### 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?
Reply With Quote
  #2  
Old 08-07-2002, 06:53 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

replace this:
PHP Code:
$DB_site->query("UPDATE user SET usergroupid=2 WHERE userid=$key"); 
with this:
PHP Code:
$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
Reply With Quote
  #3  
Old 08-08-2002, 04:27 AM
Galen Galen is offline
 
Join Date: Apr 2002
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

But... it didn't work.

Here's the error message:

Quote:
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?
Reply With Quote
  #4  
Old 08-08-2002, 04:29 AM
Galen Galen is offline
 
Join Date: Apr 2002
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 08-08-2002, 11:15 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 08-10-2002, 03:18 AM
Galen Galen is offline
 
Join Date: Apr 2002
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #7  
Old 08-10-2002, 12:48 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes it is corrupted, perhaps you use an editor which corrupts the file at the edited lines.

try to use notepad instead
Reply With Quote
  #8  
Old 08-13-2002, 07:27 PM
Galen Galen is offline
 
Join Date: Apr 2002
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

but here's the new error message:

Quote:
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
Reply With Quote
  #9  
Old 08-13-2002, 07:37 PM
Galen Galen is offline
 
Join Date: Apr 2002
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #10  
Old 08-13-2002, 10:41 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

damn typings

It's my job to help people here
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:08 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05115 seconds
  • Memory Usage 2,249KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete