Note that there are some explanatory texts on larger screens.

plurals
  1. POPopulating depended spinner with two words
    text
    copied!<p>I am having issue with spinner populating from PHP. I have MySQL table with cities and classes. I need to take classes from specific sities. PHP for cities looks like this:</p> <pre><code>{"lista":[{"City":"Beograd"},{"City":"Novi Sad"},{"City":"Kragujevac"}]} </code></pre> <p>and when I try to populate spinner with classes from "Novi Sad" I am getting error in android </p> <pre><code>08-09 09:53:37.762: E/Fail 1(28592): java.lang.IllegalArgumentException: Illegal character in query at index 50: http://192.168.1.2/test/test.php?city=Novi%20Sad </code></pre> <p>If I call <code>http://192.168.1.2/test/test.php?grad=Novi%20Sad</code> in my localhost I am getting <code>{"lista":[{"Class":"matematika"},{"Class":"informatika"}]}</code>. If I try to populate spinner with City: Beograd or Kragujevac everything is working fine. I am guessing that problem is in empty space between Novi and Sad.</p> <p>Url for populating spinner2 from spinner1(Cities):</p> <pre><code>str_grad1=spinner1.getSelectedItem().toString(); String url="http://192.168.1.2/test/test.php?grad="+str_grad1; </code></pre> <p>EDIT: Here is also PHP script</p> <pre><code>$con = mysqli_connect($host, $user, $pwd, $db); if(mysqli_connect_errno($con)) { die("Failed to connect to MySQL: " . mysqli_connect_error()); } $sql = "SELECT Predmet FROM lista where City='".$_GET['grad']."'"; $result = mysqli_query($con, $sql); $rows = array(); while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $rows[] = $row; } mysqli_close($con); $arr = array_flip(array_map('serialize', $rows)); $lista = array_map('unserialize', array_flip($arr)); echo json_encode((object) array('lista' =&gt; array_values($lista))); </code></pre>
 

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