dongtingrun4973 2015-03-14 13:49
浏览 281
已采纳

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

Here is the code. When I execute it it shows the error message "Catchable fatal error: Object of class mysqli_result could not be converted to string" Please help me to solve this problem.

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

2条回答 默认 最新

  • doumei8258 2015-03-14 13:53
    关注

    you are trying to convert the class mysqli_result to string(obviously it returns error), try this..

    $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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥30 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题