我想用mysqli
做一个简单的值计数。我有
$qnt = "SELECT COUNT(usu_nome) FROM esc_usuarios WHERE usu_indicador_codigo = '" . $_SESSION['codigo'] . "'";
$qntresul = mysqli_query($conexao, $qnt);
$colunaqnt = mysqli_fetch_array($qntresul);
但是我收到了:
致命错误:未捕获错误:无法将mysqli_result类型的对象用作数组
我正在用echo $qntresul['usu_nome']
打电话
有想法吗?
答案 0 :(得分:0)
Try this , will work fine
$qnt = "SELECT COUNT(usu_nome) as 'total' FROM esc_usuarios WHERE usu_indicador_codigo = '" . $_SESSION['codigo'] . "'";
$qntresul = mysqli_query($conexao, $qnt);
$colunaqnt = mysqli_fetch_array($qntresul);
echo $colunaqnt['total'];