Note that there are some explanatory texts on larger screens.

plurals
  1. POtrying to get array from php and store it in java,android
    primarykey
    data
    text
    <p>ive got a php file that connect to database and fetches data, now i want this data to be sent to my java code and be stored as an array, for connecting to php and retriving results i am using <strong>AsyncHttpClient</strong> now in <em>AsyncHttpClient</em> their is a func <strong>onSucess</strong> that takes a string value as its parameter, soo anything coming from php is stored as string. i want it to be array.. please suggest me a way, either to get an array instead of string following is my code.</p> <pre><code> public void func3(View view)throws Exception { AsyncHttpClient client = new AsyncHttpClient(); RequestParams rp = new RequestParams(); rp.put("pLat", "select * from iwmp_state"); client.post("http://10.0.2.2/conc2.php", rp, newAsyncHttpResponseHandler() { public final void onSuccess(Array response) { // handle your response here //tx.setText(response.toString()); } @Override public void onFailure(Throwable e, String response) { // something went wrong tx.setText(response.toString()); } }); } </code></pre> <p>and ive got a php file which echos an array <em>$row</em></p> <pre><code>&lt;?php // attempt a connection $dbh = pg_connect("host=10.22.35.11 dbname=iwmp_dev2 user=postgres "); if (!$dbh) { die("Error in connection: " . pg_last_error()); } // execute query $sql = $_POST['pLat']; $result = pg_query($dbh, $sql); if (!$result) { die("Error in SQL query: " . pg_last_error()); } $array = array(); // iterate over result set // print each row while ($row = pg_fetch_array($result)) { $i++; echo $row[0]; } // free memory pg_free_result($result); // close connection pg_close($dbh); ?&gt; </code></pre> <p>what php echos is array and what onSuccess takes as parameter is string. what to do!</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