But for some reason it is showing the resource id22
Who, where ?
You are 'mixing' here PHP and MYSQL, while you are not sure that mysql part is OK jet.
First clarify what is going on at mysql part. Separately !
My filling is you dont have a mysql client.
Get this: http://www.heidisql.com/download.php
Check what that sql client returns on:
SELECT MAX(`timestamp`) FROM replies WHERE type = 'ticket' and parent = "16"
this can no way return 'resource id22'
Then go to PHP part.
BTW - one of links to images in upper posts is broken.