Parsing UTF-8 encoded content correctly from SQL through Php with Json


SDK Version: 
M3

To get this thing working, just follow these steps:

1. First thing to do is changing the default character set of your SQL database and its tables to UTF-8.

2. Your Php file should look something like this:

  1.   $connection = mysql_connect("server_ip_address", "user", "password");
  2.  
  3.   if (!$connection) die("Couldn't connect to server");
  4.   mysql_select_db("database_name", $connection) or die("Could'nt select the database!");
  5.  
  6.   // This is very IMPORTANT!!!
  7.   mysql_query("SET NAMES 'UTF8'");  
  8.  
  9.   $sth = mysql_query($query);
  10.   $rows = array();
  11.   while($r = mysql_fetch_assoc($sth)) {
  12.       $rows[] = $r;
  13.   }
  14.   print json_encode($rows);
  15.  
  16.   mysql_close($connection);  
  17. }

3. Now you can parse these json forrmatted strings, to your application. Here's how:
http://www.helloandroid.com/tutorials/connecting-mysql-database

Comments

Android is a new software toolkit for mobile phones, created by Google and the Open Handset Alliance. In a few years, it's expected to be found inside millions thanks for sharing the information.
otc sleeping pill

Yes, Its true that Google is a company that supports internet based services so I am relieved they are improving offline usage in multiple services.The web based Google Docs is also planned to operate offline.
maid of honour speeches

Very useful tutorial
Thanks

MonaVie

Android is a new software toolkit for mobile phones, created by Google and the Open Handset Alliance. In a few years, it's expected to be found inside millions thanks for sharing the information.
Regards,
Jack - videovigilancia

Thank you - the site very very nice

المجتمع المصري هو مجتمع يحب الترفية حيث ان سكان مصر تصل الى تسعون مليون فرد ولذلك نحن نقدم خدمة دردشة مصرية لكل اهل مصر ام الدنيا , وتعتبر مصر متقدمة فى هذا العالم من حيث النمو فى مجالات التكنولوجيا و الكمبيوتر بنسبة كبيرة جدا لذلك نفضل دخول شات مصري اكبر تجمع بنات و شباب فى شات الحب و اجمل بنات فى دردشة دردشة الحب , اضافة الى ذلك حيث يوجد دردشة قوية تضم جميع محافظات مصر هي شات مصرية الكتابية نتمني لكم قضاء وقت ممكن فى شات الاصدقاء و احلي دردشة التعارف الذي يوجد به بنات رومانسية فى دردشة بنات مصر المصرية


شات الحب - دردشة مصرية - شات - شات مصري - شات حب - دردشة - دردشة كتابية - دردشة الحب - شات حبنا - شات حبي - شات مصرية - دردشة حب - شات بنات - دردشة مصر - دردشة بنات مصر - شات بنات مصر - شات صوتي - chat love - دردشة ياحبي - شات بنات لبنان - الحب - شات كتابي - منتدي ياحبي - شات مصر - دردشة حبنا - العاب تلبيس البنات - دردشة بنات - شات ياحبي - Chat - شات لبناني - شات كلامنجي - دردشة كلامنجي - شبكة - تصميم مواقع - تصميم - شات الاسكندرية - دردشة لبنانية - دردشة بنات لبنان - بنات لبنان - موقع شات - سعودي كول - شات سعودي كول - شات بنت مصر - شات سكس

hey as i have said before that i m working on a project in which i need to create some draws wich are look well in portrait mode and landscape mode too.
for that your info is nice & relevant but its not sufficient, I want some more stuff about this..!!!.000-106 // 640-822 // 1Y0-A19 // 000-977 // 000-105 // 640-816 // SY0-201 // 650-987 // 1Y0-A18 // E22-275

he webseries focuses on an exclusive Women Only dude ranch in the La Quinta desert area of Southern California. Women from all over the country leave their lives, relationships and jobs behind, to put on their cowboy boots and hats for a weekend of ranch life and friendly competition.R4 3DS \ PS3 Move \ R4 \ Pandora 3DS \ R4i Gold \ iEDGE \ CycloDS \ ez flash 3in1 \ R4 Ultra \ acekard 2i \ e3 card \ PS3 GAMES hdd \ R4i card \ PS3 controller \ ps3 jailbreak \ x360key \ 3DS card \ R4i SDHC 3DS \ R4 gold \ supercard dstwo \ M3 Real \ R4 sdhc \ R4 III SDHC \ Ez Flash \ itouchds \ PS3 user cheat \ R4i \ R4i gold 3DS \ dstt \ dstwo \ R4i RTS Platinum \ R4i SDHC \ dstti \ m3i zero \ acekard 2i 3ds \ 3ds roms \ r4ds UK \ R4 3DS \ acekard 2i \ PS3 Controller \ r4i card \ r4 \ r4i sdhc \ ez flash \ cyclods \ r4ds \ m3 real \ r4i3ds \ m3i zero \ PS3 move \ itouchds \ dstti \ iEDGE \ ezflash vi \ r4i sdhc 3ds \ cyclods ievolution \ ez flash 3in1 \ iEDGE UK \ supercard \ R4 III \ r4i rts \ acekard 2i uk \ R4i ultra \ pandora 3ds \ dstt \ r4i gold \ supercard dstwo \ ps3 jailbreak \ PS3 user cheat \ r4i

Valuable information and excellent design you got here! I would like to thank you for sharing your thoughts into the stuff you post!! Thumbs up
Generique Viagra

The Internet thanks you. nice one for sharing this with all of us.
Of course, what a great site and ... posts,I will bookmark this site.
keep doing your great job and always gain my..

Very useful tutorial
Thanks

----------------------
Cara Kerja Search Engine

I wonder how you got so good. This is really a fascinating blog, lots of stuff that I can get into. One thing I just want to say is that your Blog is so perfect!

Hey,

I've been having problems parsing UTF-8 encoded content. I've tried using this piece of script, but it doesn't wok. I just can't seem to display characters like "é" . Do i have to have certain settings on my MYSQL server?

What i do is a HTTP post with the following code:

  1. <?php
  2. $connection = mysql_connect("myserver.mysql","myDatabase","password");
  3.  
  4.   if (!$connection) die("Couldn't connect to server");
  5.   mysql_select_db("myDatabase", $connection) or die("Could'nt select the database!");
  6.  
  7.   // This is very IMPORTANT!!!
  8.   mysql_query("SET tablename 'UTF8'");  
  9.  
  10.   $sth = mysql_query($query);
  11.   $rows = array();
  12.   while($r = mysql_fetch_assoc($sth)) {
  13.       $rows[] = $r;
  14.   }
  15.   print json_encode($rows);
  16.  
  17.   mysql_close($connection);  
  18. }
  19. ?>

This is the first httppost i do before doing an actual select query. But I still get null for every word containing a character like "é". What am i doing wrong?

Thanks

I hope you will be adding more in future

Or you can use pdo, this example provide to you an PDO intance

class PDOwrapper extends PDO {
function __construct() {
$dsn = 'mysql:dbname=teszt;host=localhost';
$user = 'root';
$password = 'jelszo';
$encoding = array(1002 => "SET NAMES utf8");
parent::__construct($dsn, $user, $password, $encoding);
}
private function __clone(){}
}
...
$this->_dbh = new PDOwrapper();