 <p>You need to actually perform the query against your DB:</p> <pre><code>$stuidcheck="SELECT status FROM valid_stuid WHERE id='".$stuid."'"; if($stuidcheck == "used") </code></pre> <p>All this does is to give the string <code>$stuidcheck</code> the value "SELECT...", but you need to do something like:</p> <pre><code>$result=mysql_query($stuidcheck); $row=mysql_fetch_assoc($result); if ($row['status'] == "used") </code></pre> <p>Or something like that (my PHP is a bit rusty, but you'll find thousands of code examples for this).</p>