Error: The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
<p>I'm getting this error from a PHP file:</p>

<pre><code>The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
</code></pre>

<p>Here's a copy of the relevant code:</p>

<pre><code>&lt;?php
$con = mysql_connect("localhost","username","password");
if (!$con) {
  die('Could not connect: ' . mysql_error());
}

mysql_select_db("database_name", $con);

$result = mysql_query("SELECT COUNT(*) FROM `tbltodolist` WHERE status = 'Pending'");
$row = mysql_fetch_array($result);
$total = $row[0];

echo $total;

mysql_close($con);
?&gt;
</code></pre>

<p>Is there any simple way to switch this to using mysqli to avoid the error?</p>