sifuhall
05-25-2002, 01:48 PM
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:
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):
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:
// 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?
Here is the error I get from vBulletin:
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):
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:
// 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?