function SQL_QUERY_LOGIN_BY_SCHOOLCODE($con, $username, $opt=""){
    if(is_resource($con)){
        $q = "SELECT * FROM users WHERE username = '$username";
        $result = mysql_query($q);
        $row = mysql_fetch_array($result);
        $count = mysql_num_rows($result);
        if($count == 0) return  $opt="0";
        if($count > 1) return $opt="1";
    }
}
$mysql_login_result = SQL_QUERY_LOGIN_BY_USERNAME(MYSQL_LINK, $form_username, 1);
if($mysql_login_result == 0){
    $message = "User not registered, please register!";
}else{
    $message = "Success!";
}
Guys I have the code above to check whether the username exist or not, but when I enter the username that exist in the users table, it still echo user not registered message, what is wrong with my code?
 
    