PDA

View Full Version : Need help with a custom PHP File that needs to connect to the vbulletin DB via a link


jim6763nva
04-02-2006, 09:13 PM
I have a custom php page that I've added to the Site Navigation block. On this page I have a link that calls a php file. This php file executes a query on a table of urls in the vbulletin database to return a random record. I've tried using the following code but it doesn't seem to have access to the database object.


<?php
$sql = "SELECT worldurl FROM worlds ORDER BY RAND() LIMIT 1";
$result = $db->query_read($query);
$world = $db->fetch_array($result);
$world_url = $row["worldurl"];
header("Location: $world_url");
?>


Is there something I need to include?

Thanks in advance,
Jim