PDA

View Full Version : vBulletin Plugin programming help


flOid
01-11-2008, 12:28 PM
I'm just at programming my first vBulletin plugin. It's supposed to display current users in a IRC chat room using the a mysql statserv database. Here's the code, hook location is forumhome_start (should display within the "What's going on" section):

$doQuery=$db->query_read("SELECT nick FROM denora.user WHERE hostname NOT LIKE 'localhost.net' AND hostname NOT LIKE '%mydomain.tld%' AND online = 'Y'");
$numrows=mysql_num_rows($doQuery);
$chatters2 = "";
if($numrows>0)
{
while($chatters=mysql_fetch_array($doQuery))
{
$chatters2 .= $chatters[0];
$chatters2 .= ", ";
}
}

$chatusers = substr_replace($chatters2,"",-2);
The general code used to work in my previous IPB. However, it's just not working when I put the $chatusers variable now in the forumhome template.

What am I missing?

Opserty
01-11-2008, 01:26 PM
Try this though I don't think it will work:

$query = $db->query_read("SELECT nick FROM denora.user WHERE hostname NOT LIKE 'localhost.net' AND hostname NOT LIKE '%mydomain.tld%' AND online = 'Y'");
if($db->num_rows($query))
{
$chatters = '';
while($chatter = $db->fetch_array($query))
{
$chatters .= $chatter['nick'];
$chatters .= ', ';
}
}

$chatusers = substr_replace($chatters, '', -2);

Can you verify that the query is returning users? (Try executing in the AdminCP [> Maintenance > Execute SQL Query])

flOid
01-12-2008, 10:19 AM
Yes, it is. Already tried that.

Opserty
01-12-2008, 10:22 AM
At the bottom of your plugin temporarily run this (on the last line):

var_dump($chatusers);
What do you get returned when you view the page? (There should be something right at the top).

flOid
01-12-2008, 11:31 AM
I got it working now, tnx! :)

Opserty
01-12-2008, 12:32 PM
Ok, what was wrong?

flOid
01-12-2008, 02:48 PM
I did use your suggested code and it did work. :)