从这个线程开始:访问 MySQL 数据库 - D3
任何人都可以帮助解决我遇到的解析错误吗?关于什么可能导致这种情况的信息似乎相互矛盾?
解析错误:
错误:解析问题 d="M30,NaNL34,NaNL38,NaNL42,NaNL46,NaNL50,NaNL54,NaNL58.......
获取数据.php:
<?php
$username="*****";
$password="*****";
$host="********";
$link=mysql_connect($host,$username,$password)
or die("Unable to connect to MySQL");
mysql_select_db("*****", $link) or die( "Unable to select database"
.mysql_error());
$res = mysql_query("SELECT * FROM TestSourceSampleData")
or die ("Unable to run query");
$data = array();
while ($row = mysql_fetch_assoc($res))
{
$data[] = array("reading" => $row['reading']);
}
echo json_encode($data);
mysql_close($link);
?>
getdata.php 的输出:
[{"reading":"10"},{"reading":"10.2"},{"reading":"10.3"},{"reading":"10.3"}.......
..当打印 json 文件时:
Array[120]
[0 … 99]
0: Object
reading: "10"
__proto__: Object
1: Object
reading: "10.2"
__proto__: Object
2: Object
reading: "10.3"
__proto__: Object
3: Object
4: Object
5: Object