PDA

View Full Version : A little php help please to get this working correctly


HMBeaty
08-02-2011, 11:04 PM
I'm working on making a hit counter for the forumhome and so far, have gotten this far with the code:

Plugin
Hook location: forumhome_start
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "usml_fhcounter SET count = count + 1");
$counter = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "usml_fhcounter");
$count = vb_number_format($counter['count']);

$template_hook['navtab_end'] .= '<phrase 1="$count">'.$vbphrase[counter].'</phrase>';
Installcode
$db->hide_errors();

$db->query_write('CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'usml_fhcounter`(
`count` VARCHAR(6) NOT NULL DEFAULT "",
PRIMARY KEY (`count`)
) TYPE=MyISAM;
');

$db->query_write('INSERT INTO `'.TABLE_PREFIX.'usml_fhcounter` (
VALUES (0);
');

$db->show_errors();
It ALMOST works! The only problem I'm having is that it is printing out
Visitors: %1$s
So, how do I get %1$s to display as the number of visitors instead of.....whatever that is? lol

Thanks in advance for the help :)

Lynne
08-02-2011, 11:34 PM
I think you want to use construct_phrase:

construct_phrase($vbphrase['counter'], $counter)

So something like:
$template_hook['navtab_end'] .= construct_phrase($vbphrase['counter'], $counter);

HMBeaty
08-02-2011, 11:37 PM
Just tried that, an now no characters show. Just:
Visitors:
Hopefully that's an improvement lol

Lynne
08-02-2011, 11:40 PM
Whoops, you need to pas $count, not $counter.

$template_hook['navtab_end'] .= construct_phrase($vbphrase['counter'], $count);