gpt4 book ai didi

php - 选择语句无法正常工作

转载 作者:行者123 更新时间:2023-11-30 23:13:57 25 4
gpt4 key购买 nike

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

最佳答案

你缺少 $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();

关于php - 选择语句无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18744621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com