I'm new to PHP programming and have poor knowledge about it, but I want to use it to make web services to my client Android application...
I began making my first web service with PHP and it's working fine, but I want to know how I can make one file that has all my functions and methods that I need and how to call it from Android
Thank you
This is 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();
}
?>
and the URL http://localhost/mywebservices.php?op=GetAllCategory&lang_id=1&rest_id=1
and i got this error now
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in
C:\xampp\htdocs\functions.php on line 22
Notice: Undefined variable: output in C:\xampp\htdocs\functions.php on line 24
null