1

在我从数据库中选择之后,当它实际上是 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 不为空

4

1 回答 1

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();
于 2013-09-11T15:12:01.247 回答