cocciuto eh?
NON PUOI VALIDARE IL CODICE PHP! DEVI DARGLI SOLO L'OUTPUT!
forse usando <script type="text/php"> invece di <?php e ?> ci riesci.