2015-04-25 102 views
0

當試圖建立與mysql的連接時,出現以下錯誤。在logcat的連接Android PHP/MySQL

04-25 18:41:37.447: W/AudioTrack(347): AUDIO_OUTPUT_FLAG_FAST denied by client 
04-25 18:41:37.937: I/logar(1290): resposta = <br /> 
04-25 18:41:37.937: I/logar(1290): <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'> 
04-25 18:41:37.937: I/logar(1290): <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Notice: Undefined index: senha in C:\wamp\www\PhpAndroid\Contexto.php on line <i>7</i></th></tr> 
04-25 18:41:37.937: I/logar(1290): <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> 
04-25 18:41:37.937: I/logar(1290): <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> 
04-25 18:41:37.937: I/logar(1290): <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0000</td><td bgcolor='#eeeeec' align='right'>244656</td><td bgcolor='#eeeeec'>{main}()</td><td title='C:\wamp\www\PhpAndroid\Contexto.php' bgcolor='#eeeeec'>..\Contexto.php<b>:</b>0</td></tr> 
04-25 18:41:37.937: I/logar(1290): </table></font> 
04-25 18:41:37.937: I/logar(1290):  
04-25 18:41:37.937: I/logar(1290): 
04-25 18:41:37.972: I/Choreographer(1290): Skipped 160 frames! The application may be doing too much work on its main thread. 
04-25 18:49:40.900: I/UsageStatsService(347): User[0] Flushing usage stats to disk 
04-25 18:59:46.709: I/ProcessStatsService(347): Prepared write state in 20ms 
04-25 18:59:46.770: I/ProcessStatsService(347): Prepared write state in 4ms 
04-25 18:59:46.871: I/ProcessStatsService(347): Pruning old procstats: /data/system/procstats/state-2015-04-20-17-04-33.bin 
04-25 19:01:00.011: I/ActivityManager(347): Killing 757:com.android.music/u0a33 (adj 13): empty for 1802s 
04-25 19:01:00.132: I/ActivityManager(347): Killing 693:com.android.printspooler/u0a39 (adj 15): empty for 1811s 
04-25 19:01:46.852: I/ActivityManager(347): Killing 1011:com.android.settings/1000 (adj 13): empty for 1819s 
04-25 19:01:46.976: I/ActivityManager(347): Killing 961:com.android.managedprovisioning/u0a8 (adj 15): empty for 1824s 
04-25 19:01:47.044: I/ActivityManager(347): Killing 923:com.android.dialer/u0a4 (adj 15): empty for 1827s 
04-25 19:02:00.016: I/ActivityManager(347): Killing 1088:com.android.exchange/u0a27 (adj 15): empty for 1810s 
04-25 19:02:00.067: I/ActivityManager(347): Killing 802:android.process.media/u0a5 (adj 15): empty for 1811s 
04-25 19:04:47.610: I/art(656): Background partial concurrent mark sweep GC freed 4927(338KB) AllocSpace objects, 0(0B) LOS objects, 25% free, 1520KB/2032KB, paused 1.151ms total 383.637ms 

package com.example.projetoansc; 

import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.io.UnsupportedEncodingException; 
import java.util.ArrayList; 
import java.util.List; 

import org.apache.http.HttpEntity; 
import org.apache.http.HttpResponse; 
import org.apache.http.NameValuePair; 
import org.apache.http.client.ClientProtocolException; 
import org.apache.http.client.entity.UrlEncodedFormEntity; 
import org.apache.http.client.methods.HttpPost; 
import org.apache.http.impl.client.DefaultHttpClient; 

import android.os.AsyncTask; 
import android.util.Log; 

public class Conexao extends AsyncTask<String, String, String> { 

    List<NameValuePair> postparams= new ArrayList<NameValuePair>(); 
    private String url=null; 


    public Conexao(String url, List<NameValuePair> params){ 
     this.postparams = params; 
     this.url = url; 
    } 

    @Override 
    protected String doInBackground(String... params) { 

     try{ 
      DefaultHttpClient client = new DefaultHttpClient(); 
      HttpPost httpPost = new HttpPost(url); 
      httpPost.setEntity(new UrlEncodedFormEntity(postparams)); 

      HttpResponse httpResponse = client.execute(httpPost); 
      HttpEntity httpEntity = httpResponse.getEntity(); 

      BufferedReader reader = new BufferedReader(new InputStreamReader(httpEntity.getContent())); 
      StringBuilder sb = new StringBuilder(); 
      String line = null; 
      while ((line = reader.readLine()) != null) { 
       sb.append(line + "\n"); 
      } 
      return sb.toString(); 

      }catch (UnsupportedEncodingException e) { 
       e.printStackTrace(); 
      } catch (ClientProtocolException e) { 
       e.printStackTrace(); 
      } catch (IOException e) { 
       e.printStackTrace(); 
      } 


     return ""; 


    } 
} 

//And the class that class that call this object Conexao.class 

public void onClick(View v) { 
    String url = "http://myhost/phpandroid/Contexto.php"; 

    ArrayList<NameValuePair> parametros = new ArrayList<NameValuePair>(); 

    parametros.add(new BasicNameValuePair("nome",editText1.getText().toString())); 
    parametros.add(new BasicNameValuePair("nome",editText2.getText().toString())); 



    try{ 
     String resultado = new Conexao(url, parametros).execute().get(); 

     if(resultado.equals(editText1.getText().toString())){ 
      Log.i("logar", "resposta = "+ resultado); 
     } 
     else{ 
      Log.i("logar", "resposta = "+ resultado); 
     } 


    }catch(Exception e){ 
     Log.i("logar", "erro = " + e); 
    } 
} 

錯誤會發生什麼是變量resultado是從MySQL接收一個大的HTML代碼,而不是我的DATAS。

+0

讓我明白,而不是JSON你收到的HTML代碼? –

+0

發表你的結果(你的日誌) –

+0

我的腳本PHP的迴應只是一個迴應,從MySQL收到的日期可能是因爲這我收到一個大代碼的HTML,只是想知道在哪裏我失蹤 –

回答

0

這裏是

parametros.add(new BasicNameValuePair("nome",editText1.getText().toString())); 
parametros.add(new BasicNameValuePair("nome",editText2.getText().toString())); 

的兩個參數有爲什麼「senha」不會被定義它們的變化之一「諾姆」那是實際問題「senha」

+0

哦...我現在發現,這是有罪CTRL + V :) –

+0

是的,我知道,hhhh –