简体   繁体   中英

How can i test PHP/MySQL web service on the server

I have implemented a PHP/MySQL web-service to deal with my iPhone application, and when i want to test it on the localhost, everything went great exception when i try to send the JSON encoded response: $liste_des_themes=array();

$liste_des_themes=array("Préfectures et sous-préfectures","Mairie","Banque","Restaurant");
        $in_list = "'".implode("','", $liste_des_themes)."'";
        $stmt = $this->db->prepare('SELECT libelle,activite,adresse,tel,lat,lng FROM etablissements where type IN ('.$in_list.')');
        $stmt->execute();
        $stmt->bind_result($libelle,$activite,$adresse,$tel,$lat,$lng);
        while ($stmt->fetch()) {
            echo "$libelle | $activite | $adresse | $tel | $lat | $lng<br/>";
        }
        $stmt->close();     

        $result = array("themes" => $stmt);
        sendResponse(200, json_encode($result));
        return true;

I intend to invoke my web-service with a POST request, for the moment i try just to test it, i don't know but i suppose it should return me a JSON data with the famous JSON {} , however i got this error:

Fatal error: Call to undefined function sendResponse()

sendResponse is not a php function.

Try this:

$result = array("themes" => $stmt);
        echo json_encode($result);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM