code suddenly appearing from my tempate second loop

Are you absolutely certain that you don’t accidentally have a closing php tag where you shouldn’t? – yes – turned out to be that I had <? rather than <?php – probably the new server was set differently – as per https://stackoverflow.com/questions/2185320/how-to-enable-php-short-tags