从数据库中选择后,当实际为1时,我一直保持0
代码:
$username = $_SESSION['username'];
echo $username;
$sql = "SELECT activated FROM members WHERE username = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param('s', $username);
$stmt->execute();
$stmt->bind_result($emailactivated);
$stmt -> close();
echo $emailactivated;
Echo说0 ..它应该是1,注意:$ username不是空的
答案 0 :(得分:0)
你错过了$stmt->fetch()
http://php.net/manual/en/mysqli-stmt.fetch.php
$stmt = $conn->prepare($sql);
$stmt->bind_param('s', $username);
$stmt->execute();
$stmt->bind_result($emailactivated);
$stmt->fetch(); //right here
$stmt -> close();