从服务器请求数据获取null


get null from requesting data from server

我从我的云服务器请求这个php

http://54.249.251.55/php/1_index.php

但结果是空的,这是我尝试在我的本地它给我一个json结果

localhost/php/1_index.php

这是我的PHP

<?php
mysql_connect("54.249.251.55","MYID","MYPASS"); //connect database
mysql_select_db("aubook");//select name of the database
$cmd = "select * from book limit 0,20";
$sql=mysql_query($cmd);
while($row=mysql_fetch_assoc($sql))
    $output[]=$row;
print(json_encode($output));
mysql_close();
?>

MYSQL中的my Data在服务器和本地是相同的

你有什么建议吗?

在localhost上我得到这个数据

[{"bid":"B001","name":"Software design structure for Ebook application","booktype":"research","authorid":"5555555","url":"n'/a","description":""},{"bid":"B002","name":"High-level code generation for ebook viewer ontology","booktype":"research","authorid":"5555554","url":"n'/a","description":""},{"bid":"B003","name":"Toward study of photo capturing for a class of plantation investigation","booktype":"research","authorid":"1234567","url":"n'/a","description":""},{"bid":"B004","name":"Unique solution to extract spiral DNA from monkey typeA","booktype":"research","authorid":"7654321","url":"n'/a","description":""}]

请帮

提前致谢

在调试时,您需要稍微扩展一下代码来解释它:

<?php
mysql_connect("54.249.251.55","MYID","MYPASS"); //connect database
echo mysql_error();
mysql_select_db("aubook");//select name of the database
echo mysql_error();
$cmd = "select * from book limit 0,20";
$sql=mysql_query($cmd);
echo mysql_error();
while($row=mysql_fetch_assoc($sql))
    $output[]=$row;
if (count($output) == 0)
    echo "The database contained no records.";
print(json_encode($output));
mysql_close();
?>