Log in

View Full Version : what hook location should i use for this?


vietfancy
01-07-2010, 04:35 AM
I have a small famous quote table in my vb4 database. I want to get one quote randomly from the database, and post it on forumhome. so here is what i did.

I put this code in a plugin. and put $rand_quote in my forumhome template, but It doesn't work. I've tried to changed the hook location. global_start/complete/forumhome start/complete.

What did I do wrong here. Thanks

$result = $vbulletin->db->query_read("SELECT quote FROM db_name AS t1 INNER JOIN ( SELECT ROUND(RAND() * (SELECT MAX(id) FROM db_name WHERE live = '1')) AS id ) AS t2 ON t1.id >= t2.id ORDER BY t1.id ASC LIMIT 1;");

while($r = $vbulletin->db->fetch_array($result)){
$rand_quote = "$r[quote]";
}

Lynne
01-07-2010, 02:43 PM
In vB4, all variables must be registered for use in a template. Did you (pre)register that variable?

vietfancy
01-08-2010, 04:36 AM
Thanks. I got it working.