Go Back   vBulletin Setup > vBulletinSetup Information > Troubleshooting vBulletin Problems

Reply 
 
LinkBack Thread Tools Display Modes
Old 11-11-2007, 12:17 PM   #1
vBulletin Owner
 
Join Date: Oct 2007
Posts: 31
jackni will become famous soon enough
sql and plugin

how do i show the rep in the navigation bar?
i added to navbar template this

Reputation: $reputation

and i made this plugin

$query = "SELECT reputation FROM" . TABLE_PREFIX . "WHERE userid=" . $bbuserinfo[userid] . );
$reputation .= mysql_query($query);

but on the site it only says "Reputation: " and blank.
my plugin is hooked on navbits, did i get the right location? or did i mess up the sql thx
jackni is offline   Reply With Quote

Advertisement [Remove Advertisement]

Old 11-11-2007, 01:42 PM   #2
Supporters
vBulletin Owner
 
Michael Biddle's Avatar
 
Join Date: Aug 2006
Location: Anaheim, CA
Posts: 1,657
Michael Biddle is just really niceMichael Biddle is just really niceMichael Biddle is just really nice
Re: sql and plugin

try using $vbulletin->db->query_read rather then mysql_query
__________________
I hate that someone changed my signature.
Michael Biddle is offline   Reply With Quote
Old 11-11-2007, 02:51 PM   #3
vBulletin Owner
 
Join Date: Oct 2007
Posts: 31
jackni will become famous soon enough
Re: sql and plugin

it still doesn't work, should the hook be on navbits or something else?
jackni is offline   Reply With Quote
Old 11-11-2007, 03:21 PM   #4
Supporters
vBulletin Owner
 
Michael Biddle's Avatar
 
Join Date: Aug 2006
Location: Anaheim, CA
Posts: 1,657
Michael Biddle is just really niceMichael Biddle is just really niceMichael Biddle is just really nice
Re: sql and plugin

Now that I look at it, it looks like you left table out. Try:

$reputation = $vbulletin->db->query_read("
SELECT reputation
FROM" . TABLE_PREFIX . "user
WHERE userid=" . $bbuserinfo['userid']
);
__________________
I hate that someone changed my signature.
Michael Biddle is offline   Reply With Quote
Old 11-11-2007, 04:03 PM   #5
vBulletin Owner
 
Join Date: Oct 2007
Posts: 31
jackni will become famous soon enough
Re: sql and plugin

it still doesn't work, where should the hook location be?
jackni is offline   Reply With Quote
Old 11-11-2007, 04:04 PM   #6
Supporters
vBulletin Owner
 
Michael Biddle's Avatar
 
Join Date: Aug 2006
Location: Anaheim, CA
Posts: 1,657
Michael Biddle is just really niceMichael Biddle is just really niceMichael Biddle is just really nice
Re: sql and plugin

I am not sure, I have not used any hook in the navbits before.
__________________
I hate that someone changed my signature.
Michael Biddle is offline   Reply With Quote
Old 11-11-2007, 04:24 PM   #7
Supporters
vBulletin Owner
 
Michael Biddle's Avatar
 
Join Date: Aug 2006
Location: Anaheim, CA
Posts: 1,657
Michael Biddle is just really niceMichael Biddle is just really niceMichael Biddle is just really nice
Re: sql and plugin

Ok I got it. Put this in a plugin at global_start:

// Globalize Variables
global $vbulletin;

// Query It!
$reputation = $vbulletin->db->query_first("
SELECT reputation
FROM " . TABLE_PREFIX . "user
WHERE userid = '" . $vbulletin->userinfo['userid'] . "'
");


// Use $reputation[reputation] in your templates.

And use this in your template:

$reputation[reputation]
__________________
I hate that someone changed my signature.
Michael Biddle is offline   Reply With Quote
Old 11-11-2007, 04:36 PM   #8
vBulletin Owner
 
Join Date: Oct 2007
Posts: 31
jackni will become famous soon enough
Re: sql and plugin

thanks it works, but can you tell me what -> means, how query_first differs from query_read and why use $reputation[reputation] instead just $reputation?
jackni is offline   Reply With Quote
Old 11-11-2007, 04:45 PM   #9
Supporters
vBulletin Owner
 
Michael Biddle's Avatar
 
Join Date: Aug 2006
Location: Anaheim, CA
Posts: 1,657
Michael Biddle is just really niceMichael Biddle is just really niceMichael Biddle is just really nice
Re: sql and plugin

I use -> because it has to do with vbulletin operations. query_read is more for more then 1 field being pulled. and I use it like that because it is a query_first
__________________
I hate that someone changed my signature.
Michael Biddle is offline   Reply With Quote
Old 11-11-2007, 04:46 PM   #10
vBulletin Owner
 
Join Date: Oct 2007
Posts: 31
jackni will become famous soon enough
Re: sql and plugin

thankssss
jackni is offline   Reply With Quote
Old 11-12-2007, 05:52 AM   #11
vBulletin Owner
 
Join Date: Nov 2006
Location: Florida
Posts: 195
noppid is a jewel in the rough
Re: sql and plugin

Query first does the query and than puts the result in an array with mysql_fetch_array().

In your first example, mysql_query returns a mysql resource that you can grab the content of with mysql_fetch_array() and then access.

You should use the vB mysql wrapper when coding.

$vbulletin->db->query_first to get one row returned in an array.
$vbulletin->db->query_read to get multiple rows that you can then fetch and parse.
$vbulletin->db->query_write to write to tables.
noppid is offline   Reply With Quote
Old 11-15-2007, 07:55 PM   #12
entrepreneur
 
Join Date: Nov 2007
Posts: 5
anuvenkatesh will become famous soon enough
Re: sql and plugin

Hi i'm trying to do something similar.

Here is what i want to do...
i need to add a new field categoryid to the forum table.
Then i want to be able to use this categoryid (for each specific forum) in a plugin which will parse the contents of a page from another website of ours but needs this categoryid.


i tried the hook location 'global_start'
ob_start();
$categoryid = $foruminfo[categoryid];
include('[domainname]/API/ads.cfm?w=160&h=600&as=2&q=&f=0&categoryid=$catego ryid');
$includedphp = ob_get_contents();
ob_end_clean();

since $foruminfo[categoryid] doesn't print anything, how do i accomplish this.?
anuvenkatesh is offline   Reply With Quote
Reply 
vBulletin Setup > vBulletinSetup Information > Troubleshooting vBulletin Problems

Tags
plugin, sql

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
May I know whicht plugin is this? Glitto Troubleshooting vBulletin Problems 7 08-03-2009 03:13 PM
How to exclude forum from a plugin Cerberus Troubleshooting vBulletin Problems 4 06-07-2009 04:51 PM
Whats the name of the plugin/hack your useing? sith717 General Discussion 2 06-23-2008 02:22 PM
Looking for vBulletin OpenID Plugin growgirl Buy Sell Websites, Sell a Scripts & Apps 6 12-04-2007 11:44 AM
plugin hook location anuvenkatesh Troubleshooting vBulletin Problems 0 11-16-2007 02:15 PM


All times are GMT -8. The time now is 06:29 PM.