gpt4 book ai didi

php - 数据类型为 TEXT 或 Varchchar 的列在 json 中返回 null,即使它不是

转载 作者:行者123 更新时间:2023-11-29 20:15:26 24 4
gpt4 key购买 nike

我有一个返回 JSON 数组的 php 文件

<小时/>
NAME          TYPE            COLLATION               NULL
title varchar(50) latin1_swedish_ci No
description text latin1_swedish_ci No

描述字段返回 null,即使其中有数据

<小时/>

Json:

{
"pd_main": [
{
"id": "1",
"title": "Attire",
"description": null,
"time_stamp": "2016-09-03 01:35:55",
"cat": "sa",
"sub_cat": "sa",
"image": "sa",
"icon": "sa"
}
]
}

php文件

$sql = "select * from pd"; 

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

if($rowcount=mysqli_num_rows($result))
{
while($row = mysqli_fetch_assoc($result))
{
$resul[] = $row;

}
}
mysqli_close($con);
echo json_encode(array("pd_main"=>$resul));
<小时/>

如果我减少描述中的内容,那么它会出现在 json 中,但我想要大文本

最佳答案

可以使用json_last_error_msg()这个函数来检查是否有错误。 http://php.net/manual/en/function.json-last-error-msg.php

关于php - 数据类型为 TEXT 或 Varchchar 的列在 json 中返回 null,即使它不是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39815310/

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