Log in

View Full Version : Quick help with PHP. (PLEEEAAASSE!!)


NoRespect
01-01-2006, 01:52 AM
I am wanting to run a script every so often, to move any threads with more than 1 reply from certain forums to another. Currently I have redirect.php under /includes/cron, but when I run it, nothing happens.

Here is the code:

<?php

$db->query("UPDATE " . TABLE_PREFIX . "thread SET forumid = 2 WHERE forumid = 11 AND replycount >= 1");
$db->query("UPDATE " . TABLE_PREFIX . "thread SET forumid = 2 WHERE forumid = 9 AND replycount >= 1");
$db->query("UPDATE " . TABLE_PREFIX . "thread SET forumid = 2 WHERE forumid = 10 AND replycount >= 1");
$db->query("UPDATE " . TABLE_PREFIX . "thread SET forumid = 2 WHERE forumid = 8 AND replycount >= 1");
$db->query("UPDATE " . TABLE_PREFIX . "thread SET forumid = 2 WHERE forumid = 12 AND replycount >= 1");

require_once('./includes/functions_databuild.php');
build_forum_counters(8);
build_forum_counters(9);
build_forum_counters(10);
build_forum_counters(11);
build_forum_counters(12);
build_forum_counters(2);

log_cron_action('Threads with replies moved from Forum 11, 9, 10, 8, and 12 to Forum 2', $nextitem);

?>


Help? :ermm:

Paul M
01-01-2006, 02:05 AM
Is that all that's in the file ?

"$db->query" should probably be "$vbulletin->db->query_write"

:)

NoRespect
01-01-2006, 02:06 AM
Is that all that's in the file ?

"$db->query" should probably be "$vbulletin->db->query_write"

:)

Yes. Should there be more? :speechless:

IT WORKED! A million thanks. :)

Paul M
01-01-2006, 02:13 AM
Not absolutely necessary, but it's normal to include a check like this at the top of a cron file ;

// Database connection ?
if (!is_object($vbulletin->db)) exit;

IT WORKED! Well yes, do try not to seem too surprised ;) :p

jugo
01-01-2006, 02:17 AM
LOL...hey thanks PAUL...this answered a question for me as well.

WOWSERS!!!! lol