I used this tutorial: http://www.helloandroid.com/tutorials/connecting-mysql-database
This is performing awesome. But I got this name Eugène but when I try to take that name out of the database, it gives a nullPointer, however when I change it to Eugne, then it shows the name.
Is it possible to show/take characters like “è” from database to android?
I read some tutorials, but I can’t get it to work.
<?php
mysql_connect("127.0.0.1","root","root");
mysql_select_db("peopledata");
$q=mysql_query("SELECT * FROM people2 WHERE voornaam LIKE '%%'");
//$q=mysql_query("SELECT * FROM people WHERE voornaam ='""'");
while($e=mysql_fetch_assoc($q))
$output[]=$e;
print(json_encode($output));
mysql_close();
?>
This is my android java part:
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
android.util.Log.e("log_tag",
"Error converting result " + e.toString());
}
EDIT 1
08-22 16:24:56.935: I/log_tag(14424): id: 3, name: null;
But it isn’t showing an error
Found an answer:
Put this line :
mysql_query("SET NAMESutf8");before you connect to database.So from:
To: