title: PHP/MYSQL Duplicate Email Address
body: <p>I am trying to prevent users on a site I'm working on from having duplicate email addresses. This is the method I'm using:</p>
  
  <pre><code>function createUser( $emlAd )
  {
       $sql = "SELECT FROM Users WHERE email='$emlAd'" ;
  
       $result = mysql_query( $sql ) ;
  
       if( mysql_num_rows( $result ) &gt; 0 )
       {
   die( "There is already a user with that email!" ) ;
       }//end if
  
       //rest of function
  }//end createUser
  </code></pre>
  
  <p>This code does not accomplish its task, and the user is still able to create an account with an already used email. The weird thing is that when I change the if condition to:</p>
  
  <pre><code>mysql_num_rows( $result ) == 0 
  </code></pre>
  
  <p>The user isn't able to create an account with any email address. Why does the code not pass control to the if block when the number of rows is greater than 0?</p>