Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7762073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:17:57+00:00 2026-06-01T14:17:57+00:00

I’m new to PHP programming and have poor knowledge about it, but I want

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:17:59+00:00Added an answer on June 1, 2026 at 2:17 pm

    As an idea, I’d recommend including the function name desired to run in your url.
    And then, get that function name and arguments, pass them to php’s

    call_user_func_array()
    

    function.

    Here’s a very basic idea of a function handler:

    your request URL would look like this:

    http://www.mysite.com/webservice.php?op=CallFunctionOne&param_a=test&param_b=test2
    

    And here is the handler to route your calls to your functions:

    require_once("./functions.php");
    
    if(!empty($_SERVER["QUERY_STRING"])){
        $query_str = stripslashes($_SERVER['QUERY_STRING']);
        parse_str($query_str,$args);
        $op = array_shift($args);
        if(is_callable ($op)){
            call_user_func_array($op,$args);
        }
        else{
            echo "Handler error.<br />";
            echo $op . " function is not callable.";
        }
    }
    

    And functions.php file would include your functions.
    Hope it will give some idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want to construct a data frame in an Rcpp function, but when I
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.