PDO not working - simply displaying some of the code as if it wasn't PHP : <p>I'm new to PDO, so I apologise if this is a silly question. I have two files: writel.html contains a simple form, with formaction="submitArticle.php" and method="post". submitArticle.php contains the following:</p>

<pre><code>&lt;?php

$con = new PDO('mysql:host=localhost;dbname=mysql','root','root');

$submission = $con-&gt;prepare("
    INSERT INTO sfWritings(title, summary, content)
    VALUES(:title, :summary, :content)
    ");

$submission_execution = $submission-&gt;execute([
    'title' =&gt; $_POST['title'],
    'summary' =&gt; $_POST['summary'],
    'content' =&gt; $_POST['content']
    ]);

if($submission_execution) {
    echo "article submitted";
}
?&gt;
</code></pre>

<p>However, instead of getting either the echo message, or some sort of error, I simply get the whole code, as if it doesn't realise it's PHP or something:
<a href="https://i.stack.imgur.com/UYVBR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UYVBR.png" alt="Screenshot"></a></p>

<p>If I add some html tags (<code>&lt;html&gt;</code>, <code>&lt;body&gt;</code> etc.) then it starts giving me this:
<a href="https://i.stack.imgur.com/tLH8F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tLH8F.png" alt="Screenshot when using html tags"></a></p>

<p>The database is ok (I've been able to fetch some test data from it). And the way I'm doing the insert closely follows a (working) example for a tutorial. So I''m a bit stuck for what I'm doing wrong!</p>
