Php 错误的json字符串操作

Php 错误的json字符串操作,php,mysql,json,amazon-ec2,Php,Mysql,Json,Amazon Ec2,我已经创建了一个页面,它从表view\u name中获取数据,并使用google graph API显示图表。 当我在本地主机上运行系统时,它会给出正确的结果并显示图表 当我在ec2 linux iNtance上创建相同的数据库并获取相同的文件时,其他一切都正常工作,只是图形没有出现。我检查了firebug结果,结果显示进入localhost的json字符串获取了正确的数据,而在ec2实例上,json字符串为false 在localhost上运行时的json字符串: {“cols”:[{“lab

我已经创建了一个页面,它从表
view\u name
中获取数据,并使用google graph API显示图表。 当我在本地主机上运行系统时,它会给出正确的结果并显示图表

当我在ec2 linux iNtance上创建相同的数据库并获取相同的文件时,其他一切都正常工作,只是图形没有出现。我检查了
firebug
结果,结果显示进入localhost的
json字符串
获取了正确的数据,而在ec2实例上,json字符串为false

在localhost上运行时的json字符串:
{“cols”:[{“label”:“pcount”,“type”:“string”},{“label”:“ncount”,“type”:“number”}],“rows”:[{“c”:[{“v”:“pcount”},{“v”:179}},{“c”:[{“v”:“ncount”},{“v”:237}]}}

在ec2实例上运行时的json字符串:
{“cols”:[{“label”:“pcount”,“type”:“string”},{“label”:“ncount”,“type”:“number”},“rows”:[{“c”:[{“v”:“},{“v”:0}]},{“c”:[{“v”:“0}]},{“c”:[{“v”:“v”:“},{“v”:0},{“c”:[{“v”:“v”:“v”:“},{“v”:“},{”0},{“v”:“},{“v”:”},{“v”:“},},{“v”:

我的桌子是:

+----------+-----------+
| ind_type | Index_val |
+----------+-----------+
| pcount   |       179 |
| ncount   |       237 |          which is same on localhost and ec2 instance.
+----------+-----------+
我的php页面url.php,其中包含GUI按钮:

<html>
   <head>
      <title>ThenWat</title>

    <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
    <meta content="utf-8" http-equiv="encoding" />
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>   
     <script type="text/javascript" src="https://www.google.com/jsapi"></script>
     <script type="text/javascript">
    google.load('visualization', '1', {'packages':['corechart']});
    google.setOnLoadCallback(drawChart);    


    function drawVisualization(dataFromAjax) {

    var jsonData = $.ajax({
          url: "ajax_graph_temp.php",
          dataType:"json",
          async: false
          }).responseText;
    var data = new google.visualization.DataTable(jsonData);
        var options = {
           title: 'Index analysis',
          is3D: 'true',
          width: 800,
          height: 600
        };
        var chart = new google.visualization.PieChart(document.getElementById('txtHint'));
        chart.draw(data, options);
         }
function makeAjaxCall() {
      $.ajax({url:'url.php',
              data: {},
              success: function(responseData) {
                         drawVisualization();
                       }
        });
    }
     </script>
   </head>
   <body style="height: 560px">
         <div style="z-index: 1; left: 660px; top: 160px; position: absolute; margin-top: 0px"> 
            <button onclick="makeAjaxCall(); return false;" value="View Graph" > View Graph </button>
         </div>

         <div id="txtHint" style="z-index: 1; left: 220px; top: 250px; position: absolute; margin-top: 0px">        
         </div>

   </body>
</html>

森瓦特
load('visualization','1',{'packages':['corechart']});
setOnLoadCallback(drawChart);
函数drawVisualization(dataFromAjax){
var jsonData=$.ajax({
url:“ajax\u graph\u temp.php”,
数据类型:“json”,
异步:false
}).responseText;
var data=新的google.visualization.DataTable(jsonData);
变量选项={
标题:“指数分析”,
is3D:'正确',
宽度:800,
身高:600
};
var chart=new google.visualization.PieChart(document.getElementById('txtHint');
图表绘制(数据、选项);
}
函数makeAjaxCall(){
$.ajax({url:'url.php',
数据:{},
成功:功能(responseData){
绘图可视化();
}
});
}
视图图
ajax调用中的ajax_graph_temp.php调用是:

<?php
$mysqli =mysqli_connect('127.0.0.1:3306', 'root', 'root', 'test');
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: ".mysqli_connect_error();
}
  $result = $mysqli->query('SELECT * FROM view_name');

  $rows = array();
  $table = array();
  $table['cols'] = array(
    array('label' => 'pcount', 'type' => 'string'),
    array('label' => 'ncount', 'type' => 'number')
);
    /* Extract the information from $result */
    foreach($result as $r) {
      $temp = array();
      $temp[] = array('v' => (string) $r['ind_type']); 
      $temp[] = array('v' => (int) $r['Index_val']); 
      $rows[] = array('c' => $temp);
    }

$table['rows'] = $rows;

// convert data into JSON format
//$jsonTable = json_encode($table);

$jsonTable = json_encode($table);

echo $jsonTable;
?>


本地主机和ec2实例上的一切都是一样的。问题出在哪里?我是否在任何地方出错?

url.php在做什么?在我看来,您在te EC2版本上读取的表中没有正确的数据,或者您读取了错误的表。@AmalMurali:这是第一个包含gui的文件,单击按钮。我又加了一句name@MikeW:谢谢,我也觉得一样,但我查的表名都一样。事实上我复制了同一个文件。表中也包含与我前面提到的相同的数据。我知道不可能有魔法!但是我不知道错误隐藏在哪里..每个环境中运行的php版本是什么?