gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 22:46:53 25 4
gpt4 key购买 nike

这是代码。当我执行它时,它显示错误消息“可捕获的 fatal error :类 mysqli_result 的对象无法转换为字符串”请帮我解决这个问题。

$sql = "SELECT dname FROM bdonor WHERE DID = 2";
$dname = $con->query($sql);
echo $dname;

最佳答案

您正在尝试将 mysqli_result 转换为字符串(显然它会返回错误),请尝试此操作..

$sql = "SELECT dname FROM bdonor WHERE DID = 2";
$result= $con->query($sql);
while($row = $result->fetch_array(MYSQLI_ASSOC))
echo $row['dname '].'<br />'; // here is the output display line by line

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

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