vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   database question (https://vborg.vbsupport.ru/showthread.php?t=39039)

sifuhall 05-25-2002 12:48 PM

database question
 
I want to include a random entry from a table in another database. My script returns the random entry just fine, but when I call it from vBulletin it doesn't work.

Here is the error I get from vBulletin:

Code:

Warning: 1 is not a valid MySQL-Link resource in /home/virtual/site19/fst/var/www/html/discussion/admin/db_mysql.php on line 120

Here is the script (with the userid and password removed):

PHP Code:

function getDidYouKnow(&$didyouknow) {
    
$newdb mysql_connect("localhost"$mydbuser$mydbpass);

    
// get random entry
    
$myquery "SELECT * FROM didyouknow ORDER BY RAND() LIMIT 1";
    
$myresult mysql_db_query($mydbname$myquery); 
    if (
$myresult) {
        
$dykr mysql_fetch_array($myresult);
        
$didyouknow $dykr["info"];
    }
    
mysql_free_result($myresult);
    
mysql_close($newdb);


And I call this in the phpinclude template like this:

Code:

// get common page vars
require "***edited path to the file ***/common.php";
// get Did You Know
getDidYouKnow($didyouknow);

So why does this screw up vBulletin's database reference?

sifuhall 05-26-2002 12:01 AM

Got it, mysql_select_db was the solution.

Regit 08-17-2002 12:16 AM

you got it ? how ?
i have the same problem , please post your solution code here !

sifuhall 08-17-2002 11:28 AM

Just use mysql_select_db to reselect your forum database when you exit your routine


All times are GMT. The time now is 08:38 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.01676 seconds
  • Memory Usage 1,718KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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