mysqli_result类的对象无法转换为字符串,返回mysql的平均值 [英] Object of class mysqli_result could not be converted to string return mysql average

查看:57
本文介绍了mysqli_result类的对象无法转换为字符串,返回mysql的平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释我将如何输出以下sql的结果吗?当前正在获取无法将mysqli_result类的对象转换为字符串".

Can someone explain how I would output the result of the sql below? currently getting 'Object of class mysqli_result could not be converted to string'.

$sql = ("SELECT AVG(ab_satisfactionScore) AS AverageSatisfactionScore
     FROM tbl_appointmentsbooked;");

$result = mysqli_query($connection, $sql);

echo ($result);

推荐答案

由于回显对象而出错,因此请尝试这样

Error because you are echoing an object, so try like this,

while($res = mysqli_fetch_array( $result )) {
    echo $res['AverageSatisfactionScore'];
} 

这篇关于mysqli_result类的对象无法转换为字符串,返回mysql的平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆