gpt4 book ai didi

php - 使用 PHP 生成包含大量行的 JSON

转载 作者:行者123 更新时间:2023-11-29 19:18:25 25 4
gpt4 key购买 nike

我使用下面的代码生成 JSON,在本地 WAMP 服务器上正常工作。但是,当我将文件导出到 WEB 时,脚本仅在 SELECT 中生成带有几个库的 json,如果查询大于 10 个结果,它不会生成任何内容,本地服务器上不会发生这种情况。

有人遇到过这个问题吗?是不是要编辑PHP.ini文件什么的?

   <?php
//open connection to mysql db
$connection = mysqli_connect("localhost","root","123","vendas") or die("Error " . mysqli_error($connection));

//fetch table rows from mysql db
$sql = "SELECT * FROM os WHERE id_user = 15 and data_conclusao = '2017-03-02'";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));

//create an array
$emparray = array();
while($row =mysqli_fetch_assoc($result))
{
$emparray[] = $row;
}
echo json_encode($emparray);

//close the db connection
mysqli_close($connection);
?>

最佳答案

检查您的数据是否包含 UTF-8 字符。当然,尝试将您的代码替换为:

while($row =mysqli_fetch_assoc($result)) {
$emparray[] = array_map('utf8_encode', $row);
}

关于php - 使用 PHP 生成包含大量行的 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42578291/

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