Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在将结果获取到android客户端时,从mongodb操作光标结果时出错_Php_Android_Mongodb_Cursor - Fatal编程技术网

Php 在将结果获取到android客户端时,从mongodb操作光标结果时出错

Php 在将结果获取到android客户端时,从mongodb操作光标结果时出错,php,android,mongodb,cursor,Php,Android,Mongodb,Cursor,我正在从android客户端连接到本地web服务器,并从mongodb数据库获取结果 <?php $Earth_radius = 6378.137; //KM $required_distance = 20; //KM if(! isset($_POST['long']) || ! isset($_POST['lat']) ) {

我正在从android客户端连接到本地web服务器,并从mongodb数据库获取结果

<?php
        $Earth_radius = 6378.137; //KM 
                $required_distance = 20; //KM




                if(! isset($_POST['long']) || ! isset($_POST['lat']) )
                {
                    echo 'NOT SET'; //exit();

                }


                $long = $_POST['lat'];
               $lat = $_POST['long'];

                // open connection to MongoDB server
                $conn = new Mongo('localhost');

                // access database
                $db = $conn->matabatdb;

                // access collection
                $collection = $db->matabat;

                $center=array($long,$lat);
                $radius=$required_distance/$Earth_radius; //convert to radians

                echo 'Im Ok here ';

               $result = $collection->find(array("loc"=>array('$within'=>array('$centerSphere'=>array($center,$radius)))));
    echo ' I can reach here';

var_dump($result->getNext());



         echo 'I do not reach this line';



?>

对$result的任何操作都不会向android客户端提供任何反馈响应

 httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);

            HttpEntity entity = response.getEntity();
            if (entity != null) {


                String responseText = EntityUtils.toString(entity);
                Pattern pattern=Pattern.compile(".*?<body.*?>(.*?)</body>.*?",Pattern.DOTALL);

                Matcher matcher=pattern.matcher(responseText);
                if(matcher.find()) {
                    String userID = matcher.group(1).trim();


                }
                else
                    Log.i(TAG," POST RESPONSE "+ responseText);



            }
            else
                Log.i(TAG," POST RESPONSE is NULL");
httppost.setEntity(新的UrlEncodedFormEntity(nameValuePairs));
//执行HTTP Post请求
HttpResponse response=httpclient.execute(httppost);
HttpEntity=response.getEntity();
如果(实体!=null){
String responseText=EntityUtils.toString(实体);
Pattern=Pattern.compile(“.*?(.*?.*?”,Pattern.DOTALL);
Matcher Matcher=pattern.Matcher(responseText);
if(matcher.find()){
字符串userID=matcher.group(1.trim();
}
其他的
Log.i(标签,“响应后”+响应文本);
}
其他的
Log.i(标记“POST RESPONSE is NULL”);
奇怪的是,如果我制作了一个html文件并手动发布数据,那么代码可以在浏览器中运行,但是对于android,我没有收到任何返回的数据,或者更具体地说,在操纵光标后没有收到任何数据。该行之前的任何回显语句都会在Android中接收到


有什么帮助吗?

如果PHP脚本在浏览器中运行。那么这可能是一个数据编码问题


尝试使用json_encode($result->getNext())而不是var_dump($result->getNext())。

感谢您的重播。我也试过这个。还是一样的问题