English 中文(简体)
因此,通过对应的json_encode()在PHP中印刷JSON 不是显示价值观,而是一段时间?
原标题:why Printing JSON in PHP via echo json_encode() Not show values but NULL some time?

我正在使用安乐斯制造一个 app子。 在用户回答通过PHP代码储存在服务器上的SQL上。

function fetch_all_complaints_by_packet($packet) {
    global $dBConnection;

    $query = "SELECT * FROM ".DB_PREFIX ."complaint ORDER BY id DESC LIMIT 0 , 10";
    $result = mysql_query($query,$dBConnection) or die( Errant query:   .$query);

    $complaints = array();

    if(mysql_num_rows($result)) {
        $i = 0;

        while($complaint = mysql_fetch_assoc($result)) {
            $complaints[$i] = $complaint;
            echo ($complaint[ details ]. <br> );
            $i++;
        }
    }

    //echo json_encode($complaints);
}

The following line

echo json_encode();

造成错误的原因如下:NUL,但

echo json_encode($complaint[ details ]. <br> );

印刷正确的数据。 问题是什么?

最佳回答

如果问题相同,我会同大家一样检查:

当你身为“UTF-8”号大体时(无有效效力)并试图打造“JSON” 该数据编码后,该数据将汇回联合国利比里亚办事处。

我花了几个小时才能发现,在我的法典中,它毕竟是AJAX的呼声,这样你就可以真正看到错误。

我的建议是扭转错误的砍伐并显示所有错误,你可能会看到UTF-8编码的错误失败。 如果没有,则试图将数据编码为utf8,看看它是否消除了我告诉你的错误。

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签