【问题标题】:get Malformed JSON: Unexpected '?' in mysqli_fetch_row result得到格式错误的 JSON:意外的“?”在 mysqli_fetch_row 结果中
【发布时间】:2016-01-21 21:13:37
【问题描述】:

我在我的表上执行这个选择语句

$get_ads_by_category_query = "select name from sorvy_djcf_items where cat_id='38'";

if(mysqli_select_db($conn,'joyshopp_adds')){

    $result = mysqli_query($conn, $get_ads_by_category_query);

    if( mysqli_num_rows($result) > 0 ){
       $row = mysqli_fetch_row($result;
       echo $row[0];
    }

当我执行这个查询返回 Malformed JSON: Unexpected '?'在浏览器中你知道为什么会这样吗???

你有解决办法吗?

我也看到了这个How to convert an entire MySQL database characterset and collation to UTF-8? 并尝试将数据库排序规则更改为utf8,但没有成功...

【问题讨论】:

  • 你不是在呼应 JSON,你只是在呼应名字。

标签: php mysql json malformed


【解决方案1】:

使用 json_encode 返回 JSON 响应。

echo json_encode($row[0]);

【讨论】:

  • 听起来可能是整理问题,我不确定。但是您不会再收到“格式错误的 JSON”错误,是吗?
  • 我知道这可能是排序规则问题,但我将数据库排序规则更改为 utf8_general_ci 但不起作用,我还收到“格式错误的 JSON:N”
猜你喜欢
  • 2021-05-08
  • 1970-01-01
  • 1970-01-01
  • 2016-05-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多