php数组中的大文本数据

时间:2014-08-25 23:00:54

标签: php mysql json

我的代码的目标是以JSON格式返回所有db表。但我无法做到!每次我得到空的网页!这是我的代码:

$response["result"] = array();
$res = array();
$result = mysql_query("SELECT *FROM table_lessons") or die(mysql_error());
if (mysql_num_rows($result) > 0) {

        $response["version"] = 1;
        while ($row = mysql_fetch_array($result)) {
            $res["id"] = $row["id"];
            $res["band"] = $row["band"];
            $res["title"] = $row["title"];
            $res["category"] = $row["category"];
            $res["address"] = $row["address"];
            $res["song_text"] = $row["song_text"];
            $res["song_text_chords"] = $row["song_text_chords"];
            $res["provider"] = $row["provider"];
            array_push($response["result"], $res);
        }
        echo json_encode($response);

    }

我试图只推动" id"领域,它的工作原理!我认为$res["song_text"]存在问题 - 这是一个很大的TEXT字段......

var_dump($response);打印完整数组,包含所有字段......

谢谢!

我刚刚意识到,当我尝试在while块中打印单独的行时,例如:

while ($row = mysql_fetch_array($result)) {
            $res["id"] = $row["id"];
            $res["band"] = $row["band"];
            $res["title"] = $row["title"];
            $res["category"] = $row["category"];
            $res["address"] = $row["address"];
            $res["song_text"] = $row["song_text"];
            $res["song_text_chords"] = $row["song_text_chords"];
            $res["provider"] = $row["provider"];

            echo json_encode($row);

            array_push($response["result"], $res);
        }

仅显示没有西里尔字母的字段......原因是什么?

0 个答案:

没有答案