View Full Version : Having problems with calling functions
Sean S
03-31-2005, 03:37 AM
Hi everyone,
I was reading a few of the posts here and decided to test some of them and see if I learned anything, but I guess I didn't.
What I'm trying to do is I wanted to show the total number of threads on my homepage, which is not integrated to vbulletin, it is a seperate page.
I have this page saved as php and I have put this at the begining of the page,
<?php
chdir("./my forums directory/");
require('./global.php');
chdir("../");
?>
the problem I have though is that I don't know what to do from there, how do I write a command/script that would call the total number of threads from the vbulletin's database?
thank you for your help.
tnguy3n
03-31-2005, 03:50 AM
$counts = $DB_site->query("SELECT COUNT(*) AS totalthread FROM " . TABLE_PREFIX . "thread");
while($count = $DB_site->fetch_array($counts))
{
$totalthread = $count['totalthread'];
}
print("Total threads: $totalthread");
Sean S
03-31-2005, 04:10 AM
$count = $DB_site->query(SELECT COUNT(*) AS totalthread FROM " . TABLE_PREFIX . "thread");
while($count = $DB_site->fetch_array($counts))
{
$totalthread = $count['totalthread'];
}
print("Total threads: $totalthread");
thank you for your help tnguy3n, really appericiate it. The only thing is that I am getting a "prase error, unexpected T-string", do you know what might cause this error by any chance? also if it helps I use vbulletin 3, thank you.
Revan
03-31-2005, 06:35 AM
$count = $DB_site->query(SELECT COUNT(*) AS totalthread FROM " . TABLE_PREFIX . "thread");
while($count = $DB_site->fetch_array($counts))
{
$totalthread = $count['totalthread'];
}
print("Total threads: $totalthread");
Syntax error. The correct code would be $count = $DB_site->query("SELECT COUNT(*) AS totalthread FROM " . TABLE_PREFIX . "thread");
while ($count = $DB_site->fetch_array($counts))
{
$totalthread = $count['totalthread'];
}
print ("Total threads: $totalthread");
tnguy3n
03-31-2005, 10:54 AM
lol, my bad. missing a double quote, and first $count var should have s.
Sean S
03-31-2005, 02:32 PM
lol, my bad. missing a double quote, and first $count var should have s.
:D Thanks again for your help Revan and tnguy3n. I now have no errors in the page, the only problem is that the total numbers are not showing up, the only thing that shows up in the page is "Total threads:" but in front of it there is no numbers.
the code that I have so far is,
<?php
chdir("/home/***/public_html/forums");
require('/home/***/public_html/forums/global.php');
chdir("../");
$count = $DB_site->query("SELECT COUNT(*) AS totalthread FROM " . TABLE_PREFIX . "thread");
while ($count = $DB_site->fetch_array($counts))
{
$totalthread = $count['totalthread'];
}
print ("Total threads: $totalthread");
?>
tnguy3n
03-31-2005, 05:48 PM
try this one. fix $count to $counts
<?php
chdir("/home/***/public_html/forums");
require('/home/***/public_html/forums/global.php');
chdir("../");
$counts= $DB_site->query("SELECT COUNT(*) AS totalthread FROM " . TABLE_PREFIX . "thread");
while ($count = $DB_site->fetch_array($counts))
{
$totalthread = $count['totalthread'];
}
print ("Total threads: $totalthread");
?>
Deaths
03-31-2005, 05:55 PM
tnguy3n's query should work.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.