You're just making it yourself difficult to follow the code PHP Code: $username = mysql_real_escape_string( $input ); $result = mysql_query( "SELECT id FROM users WHERE username = '$username'" );