return statement not return any value in php function

410
January 26, 2017, at 06:19 AM

Can someone tell me why my return statement is not return any value in data[0] however if i choose to echo it, it shows that there is a value in data[0] but wouldn't work with the return statement.

include_once("Init/Initialize.php");
if(isset($_POST['username']) && isset($_POST['password'])){
    $username = $_POST['username'];
    function username_in_use($username){    

        $query = "SELECT COUNT(`userId`) FROM `users` WHERE `username`=?";
        $statement = mysqli_prepare($dblink, $query);
        mysqli_stmt_bind_param($statement, 's', $username);
        mysqli_stmt_execute($statement);
        $result = mysqli_stmt_get_result($statement);
        $data = mysqli_fetch_array($result, MYSQLI_NUM );
        return $data[0] ;
    }
echo username_in_use($username);
}
READ ALSO
How make output from database in excel file

How make output from database in excel file

who can make output from database(on host) as excel filexlsx ?? I'am try some codes but the file after download not work :/ must download lib for it? help meeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

269
utf-8 do not work in all

utf-8 do not work in all

I am working on web site in phpEverything was good, already created 13 different pages but on next have a problem with some character

357
Decrypt Laravel Password Reset Token

Decrypt Laravel Password Reset Token

I am writing a test that ensures that the password reset functionality of my application worksThe password reset system was created using the php artisan make:auth command

636
PDO and dependency injection

PDO and dependency injection

I'm trying to find out the best way to use PDO with my other classes without using the singleton methodI've searched dozens of questions here on stackoverflow but it's still unclear to me on how to do it

560