I want to add search function in my android app, but the problem is when i add arabic parameter to url e.g("example.com?q=بلد") it gives null result. although if i add text manually in browser to url it works fine.
InputStream inputStream = null;
String contentAsString = null;
try {
URL url = new URL("example.com?q=بلد");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.connect();
inputStream = conn.getInputStream();
contentAsString = readIt(inputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
PHP code
header('Content-Type: text/html; charset=utf-8');
mysql_select_db($this->get_databaseName(), $this->con);
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8');
$query="Select * from tbl_posts where post_title=".$_GET['q']";
Data base table field encoding method is utf8_general_ci
In simple words i want to add some arabic text as parameter in url, through which i can query database using php web service.