 <p>You have to concatenate <code>$row['mykey']</code> to <code>stmt2</code> instead of including it directly because it might be interpreted as a string.</p> <p>It should be like this</p> <pre><code>$stmt2 = $conn-&gt;prepare("SELECT client_id, companyname, contact, contractor_lock FROM table two WHERE contractor_lock = ?"); $stmt2-&gt;execute($row['mykey']); </code></pre>