PDA

View Full Version : One script changes the default database


Trana
06-23-2005, 05:14 AM
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, 05: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/function.mysql-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:

$DB_site->select_db($dbname);

or in vBulletin 3.5:

$db->select_db($dbname);

Trana
06-23-2005, 05: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, 05:56 AM
It would go in the php script.

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

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, 06:07 AM
Brad,

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