 <p>this has nothing to do with answering your question, but everything to do with improving your ability to quickly write efficient &amp; well written code:</p> <p>your way:</p> <pre><code>function user_exists($username) { $query = mysql_query("SELECT username FROM users WHERE username='$username'"); if (mysql_num_rows($query) != 0){ return true; } else{ return false; } } </code></pre> <p>better written way: </p> <pre><code>function user_exists($username) { $query = mysql_query("SELECT username FROM users WHERE username='$username'"); if(mysql_num_rows($query) &gt; 0) return true; return false; } </code></pre> <p>sql statement seems fine, as long as you are calling your function and testing it properly it should work. although unless you are sanitizing your $username input before calling user_exists, you have a gaping security exploit right there ;)</p>