Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-19-2006, 11:43 PM
maximux1's Avatar
maximux1 maximux1 is offline
 
Join Date: Mar 2002
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help with SQL

Can anyone help me with what is wrong with this query?

$db->query_first('SELECT userid, usergroupid, membergroupids, username, password, salt FROM user WHERE (username = "$username")')

I'm getting the following error from my script -

Invalid SQL:
SELECT userid, usergroupid, membergroupids, username, password, salt FROM user WHERE username = interpolated_username;

MySQL Error : Unknown column 'interpolated_username' in 'where clause'

Thanks guys,

Max
Reply With Quote
  #2  
Old 07-20-2006, 05:52 AM
Alan @ CIT Alan @ CIT is offline
 
Join Date: Nov 2004
Location: South UK
Posts: 625
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try changing it to:

PHP Code:
$db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " TABLE_PREFIX "user WHERE username = '" $username "'); 
Thanks,
Alan.
Reply With Quote
  #3  
Old 07-20-2006, 12:51 PM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Alan @ CIT
Try changing it to:

PHP Code:
$db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " TABLE_PREFIX "user WHERE username = '" $username "'); 
Thanks,
Alan.
You forgot the closing doublequote and there is no reason to concat the $username when the query is wrapped in double quotes.

PHP Code:
$db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " TABLE_PREFIX "user WHERE username = '$username'"); 
Reply With Quote
  #4  
Old 07-20-2006, 05:59 PM
maximux1's Avatar
maximux1 maximux1 is offline
 
Join Date: Mar 2002
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's my script guys, it's what I would consider pretty basic, but...for whatever reason I just can not get this to work. Im sure I am just overlooking something as I am pretty glazed from working on this. Maybe some fresh eyes can help me...

Here's the script:

PHP Code:
// get userid for given username  
$db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " TABLE_PREFIX "user WHERE username = '$username'");

    if (
$bbuserinfo['password'] != md5(md5($password) . $bbuserinfo['salt']))
    {
        
//bad password
        
die('0');
    }
    else
    {
        
//is user activated?
        
if ( $bbuserinfo['usergroupid'] == || $bbuserinfo['usergroupid'] == 
        {
            die(
'0');
        }

        
//is user banned?
        
if ( $bbuserinfo['usergroupid'] == 
        {
            die(
'0');
        }

        
//is the user an admin / super mod?
        
if ( $bbuserinfo['usergroupid'] == || $bbuserinfo['usergroupid'] == 
        {
            die(
'2');
        }

        
//user is regular user
        
die('1');
    } 
I've corrected my query to your versions, JumpD - Do you guys see whats wrong here? The problem is that it always reports that the user/pass is incorrect.

Seems simple enough, eh?

Thanks!

Max

Thanks for the help, guys!

I've figured out the problem however. The problem was not with the query that you guys helped with, it was due to the fact that I had not set the query to an array.

Learned a lot from this little excercise, thanks again!
Reply With Quote
  #5  
Old 07-21-2006, 01:22 AM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$bbuserinfo is only available in templates.

PHP Code:
$vbulletin->userinfo['password'
Same goes for the usergroup and salt ones as well.
Reply With Quote
Reply


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 05:28 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05147 seconds
  • Memory Usage 2,216KB
  • 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
  • (5)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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