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.):
// 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?