我是新来的PHP编程,并有关于它的知识贫乏,但我想用它来使Web服务我的客户端Android应用程序......PHP的Web服务与Android
我开始制作我的第一个Web服务使用PHP和它的工作很好,但我想知道我怎么可以让一个文件有我所有的函数和方法,我需要以及如何将其从Android的
调用谢谢
这是的functions.php
<?php
function GetAllRest()
{
mysql_connect("localhost","root","root");
mysql_select_db("myhoteldb");
$sql=mysql_query("SELECT rest_id ,rest_name,cuisine,no_tables,bg_img,rest_logo FROM restaurant");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
print(json_encode($output));
mysql_close();
}
function GetAllCategory($lang_id,$rest_id)
{
mysql_connect("localhost","root","root");
mysql_select_db("myhoteldb");
$sql=mysql_query("SELECT cat_lang.rowid ,cat_lang.cat_id as _id,lang_id, cat_name,cat_description from cat_lang ,menu_category WHERE lang_id= $lang_id AND restaurant= $rest_id ");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
print(json_encode($output));
mysql_close();
}
?>
和URL http://localhost/mywebservices.php?op=GetAllCategory&lang_id=1&rest_id=1
,我得到这个错误现在
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in
C:\ XAMPP \ htdocs中\ functions.php的第22行
Notice: Undefined variable: output in C:\xampp\htdocs\functions.php on line 24
null
可能重复的[警告:mysql_fetch_ *期望参数1是资源,布尔给定错误](http://stackoverflow.com/questions/11674312/warning-mysql-fetch-expects-parameter-1-to-be-resource-boolean -given-error) – j0k 2012-07-29 07:28:32