Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)

Reply
 
Thread Tools Display Modes
  #1  
Old 07-26-2004, 08:19 AM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help with an SQl query please

I've got a table in my database named usrcredit.

This table has two fields, usrname and curcredit

The usrname field matches the usernames of all forum members I've given or awarded "credits" to. The curcredit field indicates their current amount of credits.

I'm trying to call this value on a page so that it can be included in Vbulletin pages and I'm hitting a snag somewhere in my query.

here's the query:

Code:
$DB_site->query("SELECT curcredit as curcredit FROM usrcredit WHERE usrname=$bbuserinfo[username]");
$credit = $bbuserinfo[curcredit];
it's generating this error:
Fatal error: Call to a member function on a non-object in /home/www/domainname/bb/test.php on line 8

if I change the query to:
Code:
$DB_site->query("SELECT curcredit as curcredit FROM usrcredit WHERE usrname=$bbuserinfo['username']");
$credit = $bbuserinfo[curcredit];
it generates this error:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/www/domainname/bb/test.php on line 8


Line 8 is the query.

Any help would be GREATLY appreciated.

Thanks.
Reply With Quote
  #2  
Old 07-26-2004, 08:43 AM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try

Code:
$creditinfo = $DB_site->query_first("SELECT curcredit FROM usrcredit WHERE usrname='$bbuserinfo[username]'");
$credit = $creditinfo[curcredit];
Also, if you're not to far with coding yet, it might make sense to change username to userid, as that would stop some potential problems with funny characters in usernames.
Reply With Quote
  #3  
Old 07-26-2004, 08:47 AM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Colin,

Same error though

Fatal error: Call to a member function on a non-object in /home/www/domain/bb/test.php on line 8
Reply With Quote
  #4  
Old 07-26-2004, 08:53 AM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Jolten
Thanks Colin,

Same error though

Fatal error: Call to a member function on a non-object in /home/www/domain/bb/test.php on line 8
try to either change $bbuserinfo[username] to your username or echo $bbuserinfo[username], to see if that has anything in it.

[edit]try this first, I think that's the problem[/edit]
Do you have
require_once('./global.php');
somewhere at the top of your file?
If not, add that.
Reply With Quote
  #5  
Old 07-26-2004, 08:56 AM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ahh.. that got it... Thanks a bunch Colin.

I completely spaced requiring the global.php file.

it's working now.

Thanks again! You've helped make an entire community happy
Reply With Quote
  #6  
Old 07-26-2004, 09:10 AM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

my pleasure
Reply With Quote
  #7  
Old 07-27-2004, 08:47 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay anyone want to help with one more query?

I've got the table usrcredit in the database it has two feilds usrname and curcredit.
I'm tryign to populate these fields at registration by inserting the username and a given integer. I know the file I need to modify is register.php. The user gets added to teh vbulletin side but they reveive a general database error and nothing gets inserted into my two fields. Here's what I've tried:

Code:
$DB_site->query("INSERT INTO usrcredit (usrname) VALUES ($username)");
$DB_site->query("INSERT INTO usrcredit (curcredit) VALUES (100)");
I set those two queries to run after the unser information is created in vbulletin.

Any help would be appreciated.

Thanks
Reply With Quote
  #8  
Old 07-27-2004, 08:50 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try this:
$DB_site->query("INSERT INTO usrcredit (usrname, curcredit) VALUES ('$username', '100')");
Reply With Quote
  #9  
Old 07-27-2004, 09:08 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm.. that inserted the fields but the usrname field was blank.
Reply With Quote
  #10  
Old 07-27-2004, 09:12 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, try changing it to:

Code:
$DB_site->query("INSERT INTO usrcredit (usrname, curcredit) VALUES ('" . addslashes(htmlspecialchars_uni($_POST['username'])) . "', '100')");
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 11:01 PM.


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.04310 seconds
  • Memory Usage 2,248KB
  • Queries Executed 11 (?)
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_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete