return语句不返回php函数中的任何值

时间:2017-01-25 22:07:04

标签: php database mysqli

有人可以告诉我为什么我的return语句没有返回data [0]中的任何值,但是如果我选择回显它,它会显示data [0]中有一个值但是不能用于退货声明。

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);

}

0 个答案:

没有答案