Good code layout is
essential I can easily say that more organised code will gaurantee that you can troubshoot problems faster. Please, please, please layout code properly!
Here is how I would have done it (I've commented in lines I would try, to solve problems e.t.c.):
PHP Code:
<?php
// echo 'Starting file';
if ($vbulletin->options['helpcenter_auto_close'] > 0)
{
// echo 'First condition passed';
$ticketreply = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX ."helpcenter_ticket");
// echo 'query good';
while ($ticket = $vbulletin->db->fetch_array($ticketreply))
{
echo 'while good';
$ticketid =& $ticket['ticketid'];
$hc_time2 = $vbulletin->options['helpcenter_auto_close'];
$hc_timediff = intval(TIMENOW - $hc_time2);
// var_dump($ticketid, $hc_time1, $hc_time2, $hc_timediff, $ticket )
if ($ticket['datelastupdate'] <= $hc_timediff)
{
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX ."helpcenter_ticket SET ticketstatus = 0 WHERE ticketid = $ticketid");
}
}
}
?>
But whilst I was reorganising your code I found you were using [minicode]query_first()[/minicode] but you should be using [minicode]query_read()[/minicode] I suspect?