gpt4 book ai didi

php - MySQL数组到字符串转换错误

转载 作者:行者123 更新时间:2023-11-30 00:46:25 25 4
gpt4 key购买 nike

这是有问题的代码

<?php
include ("Connections/localhost.php");
$result = mysql_query("SELECT COUNT(*) AS total FROM questions LEFT OUTER JOIN answers ON questions.quest_id = answers.ans_question WHERE answers.ans_question IS null;");
$lessons= mysql_fetch_assoc($result);
?>

当我回显 $lessons 时,我得到:

Notice: Array to string conversion in C:\xampp\htdocs\gwishin\dashboard.php on line 21

我知道自上次接触 PHP/MySQL 以来事情已经发生了变化,但我认为这是正确的,或者每个查询现在都是一个数组,即使我应该只得到一个答案?

最佳答案

因为 $lessons 是一个数组。尝试一下

echo $lessons['total'];

关于php - MySQL数组到字符串转换错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21325339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com