我无法回应我的mysql查询的结果。 PHP代码是:
$getc = "SELECT credits FROM members WHERE Phone ='".$_SESSION['Phone']."'";
$credits = mysqli_query($dbc,$getc);
echo "YOU HAVE $credits CREDITS LEFT";
但是上面显示了以下错误: 可捕获的致命错误:类mysqli_result的对象无法在第204行的file.php中转换为字符串
出了什么问题?
答案 0 :(得分:1)
您只是在执行查询而不是获取结果,mysqli_query()
会返回mysqli_result而不是字段的值
$getc = "SELECT credits FROM members WHERE Phone ='".$_SESSION['Phone']."'";
$result = mysqli_query($dbc,$getc);
$row = mysqli_fetch_assoc($result);
echo "You have {$row['credits']} left!";