Yeah, that looks like it's close to workable. Just one more change:
$query = "DELETE FROM activities WHERE UNIX_TIMESTAMP(`timestamp`) < (UNIX_TIMESTAMP() - 900)";
should work. Or:
$query = "DELETE FROM activities WHERE `timestamp` < DATE_SUB(NOW(), INTERVAL 15 MINUTE)";
EDIT: My screwed-up code corrected (I hope).