显示聊天消息时出错

i'm trying to create a chatroom as an exercise, my code has a weird behavior: (PS: running with wampserver)

<?php
    header('Content-Type: application/x-www-form-urlencoded');
    try{
        $pdo_options[PDO::ATTR_ERRMODE]=PDO::ERRMODE_EXCEPTION;
        $bdd = new PDO('mysql:host=localhost;dbname=test','root','',$pdo_options);
        $msg = $bdd -> query('SELECT * FROM chatroom ORDER BY heure LIMIT 0,10');
        while($current = $msg->fetch()){
?>
            <div class='messages' ><?php echo $current['id']; ?></div><br/>
<?php
        }
        $msg->closeCursor();
    }
    catch(Exception $e){
        die('Erreur:'.$e->getMessage());
    }
?>

and I get this:

query('SELECT * FROM chatroom ORDER BY heure LIMIT 0,10'); while($current = $msg->fetch()){ ?>

closeCursor(); } catch(Exception $e){ die('Erreur:'.$e->getMessage()); } ?>

Where am I wrong? There must be a syntax error somewhere but I don't find it.

I don't know why , but I was saving the file as an html page(dit it before , no problem) and I saved it as php file and now it works.