 <p>Here is your code converted to PDO. </p> <pre><code>// Make sure the email address is available: $q = $dbc-&gt;query("SELECT user_id FROM users WHERE email=?"); $q-&gt;execute(array($e)); $r = $q-&gt;fetchColumn(); if (!$r) { // Available. // Create the activation code: $a = md5(uniqid(rand(), true)); </code></pre> <p>Three things has been corrected</p> <ol> <li>You have to always use a placeholder tp represent a variable in the query.</li> <li>To get a single value from the result, <code>fetchColumn</code> have to be used instead of <code>fetchAll</code></li> <li>No need for the manual reporting, as PDO can report its errors automatically, if confugired properly, as described in <a href="https://phpdelusions.net/pdo#errors" rel="nofollow">this tutorial</a> I wrote</li> </ol>