android+从mysql数据库中检索数据


android + retrieve data from the mysql database

我在logcat中打印了结果,所以我得到了

您没有访问此服务器上localhost的权限。。。。php脚本运行良好。

如何访问此脚本。。。请帮我

这是我的有线

    public void getData() {
        String result ="";
        InputStream isr = null;
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost post = new HttpPost("http://10.224.217.67/Parking/places.php");
            HttpResponse repons = httpclient.execute(post);
            HttpEntity enty = repons.getEntity();
            isr=enty.getContent();
            Log.d("http", "ok");
        } catch (Exception e) {
            Log.d("Error", "http error");
            viewrest.setText("Connection lost");
        }
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(isr,"UTF-8"));
            StringBuilder sb = new StringBuilder();
            String line = null;
                while ((line = reader.readLine()) != null) {
                    sb.append(line+"'n");
                }
                isr.close();
                result=sb.toString();
                Log.d("result", result);
        } catch (Exception e) {
            Log.d("Error", "converting Error");
        }

        try {
            JSONArray jArray =  new JSONArray(result);  
            String s="";
            for (int i = 0; i < jArray.length(); i++) {
                JSONObject json = jArray.getJSONObject(i);  
                s =s+"PlaceId :"+json.getInt("PlaceId")+"'n";
            }
            viewrest.setText(s);
        } catch (Exception e) {
            Log.d("Error", "Errof"+e.toString());
        }
    }

试试这个:

打开httpd.conf文件,找到这个部分:

<Directory "c:/wamp/www/">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Directory>

然后改成这样:

<Directory "c:/wamp/www/">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>

然后打开phpmyadmin.conf,找到这个

<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
</Directory>

并像这样改变:

<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

它对我有用。希望它能帮助

使用此URL更改您的URL"10.0.2.2/停车场/places.php"