gpt4 book ai didi

php - 类 mysqli_result 的对象无法转换为字符串

转载 作者:行者123 更新时间:2023-11-29 05:33:08 25 4
gpt4 key购买 nike

我收到错误:

Object of class mysqli_result could not be converted to string

这是我的代码:

$result = mysqli_query($con, "SELECT classtype FROM learn_users WHERE username='abcde'");

echo "my result <a href='data/$result.php'>My account</a>";

最佳答案

mysqli_query() 方法向您的 $result 变量返回对象资源,而不是字符串。

你需要循环它然后访问记录。您只是不能直接将它用作您的 $result 变量。

while ($row = $result->fetch_assoc()) {
echo $row['classtype']."<br>";
}

关于php - 类 mysqli_result 的对象无法转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13020298/

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