PHP Parse error: syntax error, unexpected token “endwhile” [closed]

                <?
                } else {
                } ?>

This is your problem: PHP short opening tags were deprecated in PHP 7.4 and completely removed in 8.0, so while your old server may have had 8.2.18 installed it wasn’t using it to run the site (versions of PHP can exist side by side). Replace the <? with <?php and it should work again.