PDA

View Full Version : Cannot redeclare class db_sql_vb...


Pyro
08-30-2001, 07:49 AM
Hi there,

I included several hacks on my index_homepage.php3 which is a non-vB page outside the vB directory:

Who's online on non-vB page
http://vbulletin.com/forum/showthread.php?s=&threadid=12010

Last XX Posts on non-vB page
http://vbulletin.com/forum/showthread.php?s=&threadid=12324


Total Posts on a non-vbb page
http://vbulletin.com/forum/showthread.php?s=&threadid=24226

Total Threads on a non-vbb page
http://vbulletin.com/forum/showthread.php?s=&threadid=24227


All work fine, I got all problems like "cannot include global.php3" and "cannot add more header informations" solved with the great help of this community.

Now I came to this error:

Fatal error: Cannot redeclare class db_sql_vb in ./admin/db_mysql.php3 on line 7

when I try to include the following hacks in that page:

Show Events on non-vb page
http://vbulletin.com/forum/showthread.php?s=&threadid=24939&highlight=events

Homepage Login on non-vB page
http://vbulletin.com/forum/showthread.php?s=&threadid=23524


Ok, I can roughly imagine what happened but cannot solve the problem. The hacks work fine on a single page but I cannot include them in the page where the other hacks are included. What do I have to change/delete in the last hacks to make them run properly?

As always - many thanks for your help and best regards,
Markus

merk
08-30-2001, 08:04 AM
Im guessing, its simply as you include these hacks, they incude certain files, ie functions.php

or something, and as a second one trys to call it, they fail.

Have a look thru your files, and make sure global.php(3 in your case) is only called _once_.

Thats really the only file it should be calling.

Wayne Luke
08-30-2001, 12:52 PM
Change all the include() statements to include_once() statements.

Pyro
09-03-2001, 02:28 PM
Originally posted by wluke
Change all the include() statements to include_once() statements. Hi there,

thank you for your quick help but it didn't solve my problem. I exchanged all require() and include() to include_once() but the error still occurs:

Fatal error: Cannot redeclare class db_sql_vb in ./admin/db_mysql.php3 on line 7

I guess, it has something to do with those two hacks and with the $DB_site in it.

NUMBER OF POSTS AND THREADS on non-vB page
<?php

include_once("./admin/config.php3");

$dbclassname="./admin/db_$dbservertype.php3";
require($dbclassname);

$DB_site=new DB_Sql_vb;

$DB_site->appname="VBulletin";
$DB_site->appshortname="VBulletin (forum)";
$DB_site->database=$dbname;
$DB_site->server=$servername;
$DB_site->user=$dbusername;
$DB_site->password=$dbpassword;

$DB_site->connect();


$numbersposts=$DB_site->query_first("SELECT COUNT(postid) AS posts FROM post");
$numberposts=$numbersposts[posts];

$numbersthreads=$DB_site->query_first("SELECT COUNT(threadid) AS threads FROM thread");
$numberthreads=$numbersthreads[threads];

echo "posts: $numberposts <br>threads: $numberthreads <br>";

mysql_close();
?>


CALENDAR EVENTS on non-vB page
<?php

include_once('./global.php3');

$events = $DB_site->query("SELECT DATE_FORMAT(eventdate,'%b %d') AS date, eventid, subject
FROM calendar_events
WHERE public = 1 AND eventdate >= '".vbdate('Y-m-d',time())."'
ORDER BY eventdate LIMIT 5");
if ($DB_site->num_rows($events)) {
echo "Next Five Events:<br>";
while ($event = $DB_site->fetch_array($events)) {
echo "<a href='./forum/calendar.php3?s=$session[sessionhash]&action=getinfo&eventid=$event[eventid]'>$event[subject]</a><br>";
}
} else {
echo "No Events";
}
?>



Where is the problem and what would be an easy work around for it?

Thank you!!!
Markus

badmeetsevil-
09-03-2001, 02:46 PM
Change

$DB_site=new DB_Sql_vb;

to

$DB_site="new DB_Sql_vb";

That should fix it.

badmeetsevil-
09-03-2001, 02:48 PM
Also, in the script, change .php3 to .php for include_once and the db class name.