vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Cannot redeclare class db_sql_vb... (https://vborg.vbsupport.ru/showthread.php?t=26895)

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/showthrea...threadid=12010

Last XX Posts on non-vB page
http://vbulletin.com/forum/showthrea...threadid=12324


Total Posts on a non-vbb page
http://vbulletin.com/forum/showthrea...threadid=24226

Total Threads on a non-vbb page
http://vbulletin.com/forum/showthrea...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/showthrea...ghlight=events

Homepage Login on non-vB page
http://vbulletin.com/forum/showthrea...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

Quote:

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 Code:

<?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 Code:

<?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

PHP Code:

$DB_site=new DB_Sql_vb

to

PHP Code:

$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.


All times are GMT. The time now is 03:01 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01143 seconds
  • Memory Usage 1,743KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete