2013-12-16 97 views
-1

的Android +檢索數據,我打印的結果logcat的,所以我得到PHP - 從MySQL數據庫

您沒有權限訪問此服務器上本地主機.... PHP腳本工作完美。

我如何可以訪問此腳本... plz幫助我

這裏是我的線

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()); 
     } 
    } 
+0

請參閱此鏈接烏爾錯誤 http://stackoverflow.com/questions/8366976/wamp-錯誤 - 禁止你不要有權限訪問phpmyadmin在這個s – Arun

回答

0

試試這個:

打開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> 

它爲我工作。希望它可以幫助

+0

Tnx frnd其作品 – user3107634

+0

如果我的答案解決了你的問題,你能接受它嗎?謝謝:) – MikeKeepsOnShine

-1

更改您的網址與此URL 「10.0.2.2/Parking/places.php」

+0

請解釋它是如何解決這個問題的。 –