这是我的代码。我正在尝试将值accountId返回并分配给$ accountId,但我总是返回0。查询很好,它在PHP我的管理员返回我想要的值,但它不会在这里返回它。你知道为什么吗?
$mysqli = new mysqli($SQLhost, $SQLusername, $SQLpassword, $SQLdatabase);
$stmt = $mysqli->prepare("SELECT accountId FROM Account WHERE accountUsername=? AND accountPassword=?");
$stmt->bind_param('ss', $username,$password);
$stmt->execute();
$stmt->bind_result($accountId);
$_SESSION['accountId'] = $accountId;
答案 0 :(得分:0)
工作代码:
$ mysqli = new mysqli($ SQLhost,$ SQLusername,$ SQLpassword,$ SQLdatabase);
$stmt = $mysqli->prepare("SELECT accountId FROM Account WHERE accountUsername=? AND accountPassword=?");
$stmt->bind_param('ss', $username,$password);
$stmt->execute();
$stmt->bind_result($accountID);
$stmt -> fetch();
$_SESSION['accountId'] = $accountID;