我从我的云服务器请求这个php
http://54.249.251.55/php/1_index.php
但是结果是null,这是我在我的本地尝试它给我一个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中我的数据发生了什么,服务器和本地都是相同的
你有任何消化吗?
在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":""}]
请帮忙
提前感谢
答案 0 :(得分:0)
暂时在调试时,您需要稍微扩展一下代码来解释它:
<?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();
?>