这是代码。当我执行它时,它显示错误消息“可捕获的致命错误: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