vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   One script changes the default database (https://vborg.vbsupport.ru/showthread.php?t=90874)

Trana 06-23-2005 04:14 AM

One script changes the default database
 
I recently added phpadsnew to my header to display a banner ad on every page. As a result of adding this script, my shoutbox module stopped working.

The problem seems to be that after the banner ad script executes, it leaves the default database as "bannerads" instead of "forum" (my VBB default).

I'm fairly new to VBB/PHP, so this may seem like an easy question, but how can I do a "USE FORUM" SQL command just after the banner ads script executes?

Any help would be appreciated.

Brad 06-23-2005 04:43 AM

You will need to select the vBulletin database after the code for the advert script is done.

http://us4.php.net/manual/en/functio...-select-db.php

Thats the php function you will need. If you are working with a page that includes vbulletin's global.php you would use this instead:

PHP Code:

$DB_site->select_db($dbname); 

or in vBulletin 3.5:

PHP Code:

$db->select_db($dbname); 


Trana 06-23-2005 04:47 AM

Brad,

Thank you very much for helping, no one else has suggested this.

Do I add that code to the header template or into the phpadsnew script that is listed in my php_include_start file?

Thanks.

Brad 06-23-2005 04:56 AM

It would go in the php script.

You should try adding this to the very bottom of the file right before the ?>

PHP Code:

mysql_select_db('forum'); 

Note this asumes both databases can be accessed with the same username/password. If you are using two connections some more info will need to be passed to the function. I also used native php functions because I asume the rest of that file does.

Trana 06-23-2005 05:07 AM

Brad,

Thank you very much for your help. Your suggestion worked like a charm.


All times are GMT. The time now is 08:21 PM.

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.01384 seconds
  • Memory Usage 1,716KB
  • 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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