Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieving string from MySQL-DB with java (eclipse) through json
    primarykey
    data
    text
    <p>I'm trying to program a Login-System for Android (in Eclipse) and have to get the data from an external MySQL-DB.</p> <p>Source I took the code for it: <a href="http://www.helloandroid.com/tutorials/connecting-mysql-database" rel="nofollow">Connecting to MySQL Database</a></p> <p>The Website I'm trying to fetch the data from is <a href="http://winklermarkus.at/appconnection.php" rel="nofollow">here</a>.(I know there are some safety issues, blabla, this is not my problem right now^^)</p> <p>The Problem I have, is when I try to run the Application, The Error "No Password found". This Error is catched within this Code:</p> <pre><code>ArrayList&lt;String&gt; passwort = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; benutzer = new ArrayList&lt;String&gt;(); try{ jArray = new JSONArray(result); JSONObject json_data=null; for(int i=0;i&lt;jArray.length();i++){ json_data = jArray.getJSONObject(i); passwort.add(json_data.getString("pw")); benutzer.add(json_data.getString("benutzer")); } Intent intent = new Intent(this, MainActivity.class); intent.putExtra("arrayBenutzerExtra", benutzer); intent.putExtra("arrayPasswortExtra", passwort); startActivity(intent); } catch(JSONException e1){ Toast.makeText(getBaseContext(), "No Password found" ,Toast.LENGTH_LONG).show(); } catch (ParseException e1) { e1.printStackTrace(); } </code></pre> <p>As addition, here is the code where I connect with the website, but it doesn't seem to be the problem, though I don't get an error message about that!</p> <pre><code>try{ HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://winklermarkus.at/appconnection.php"); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); }catch(Exception e){ Log.e("log_tag", "Error in http connection"+e.toString()); } </code></pre> <p>The Code of the .php file is here: <pre><code>$sql_pw = "SELECT ". "Passwort ". "FROM ". "benutzerdaten "; $result_pw = mysql_query ($sql_pw); $data_pw = mysql_fetch_array ($result_pw); $pw = $data_pw["Passwort"]; $sql_benutzer = "SELECT ". "Email ". "FROM ". "benutzerdaten "; $result_benutzer = mysql_query ($sql_benutzer); $data_benutzer = mysql_fetch_array ($result_benutzer); $benutzer = $data_benutzer["Email"]; print(json_encode($pw)); print(json_encode($benutzer)); mysql_close(); ?&gt; </code></pre> <p>as Perception mentioned, I don't get valid JSON output, could this possibly be in relation with me, trying to transmit 2 strings at once?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload